I have never done anything with bots/AI before, I'm thinking of using Goal Oriented Action Planning (GOAP) or some other type of AI (not as in machine learning, as in advanced if statements) system. I don't know where to start though. I am using RigidBody2Ds if that matters.
How to create AI/Bots for enemies? Ideally using GOAP or some other semi-advanced system
Hi, I'm currently using fsm but I recon GOAP will be a step forward and I did some research: This will be my starting point https://github.com/flags/GOAPy Hope it will be some help to you too
If you've never made AI or bots then I suggest you first start with a basic reactionary system just for the sake of experience. Something like, "Bot must get from A to B" while avoiding obstacles as they come across them to the best of its ability.
A GOAP system is as its name suggests, goal oriented action planning. This is not goal oriented action performing. This means you will have to have at least two separate AI systems. One will be the GOAP system which basically says "these things need to be done in this order" while you will have your other AI system actually figure out how to do these things one at a time. The how is the hardest part and where you would benefit from just designing some simple reactionary AI.
Now it has been years since I last designed a GOAP system, and that was also in a different engine. I basically made dummy structures to contain each "step" where each structure contained references to the structure prerequisites for the step as well as a base cost and modified cost (calculated based on certain in-game factors) of performing the step. When I used GOAP I would form a list of these structures, effectively the path of steps to some goal with minimum cost, and pass it to my second AI which would figure out how to do the actual step in the list. When the step was completed it would pop it off the list and start on the second. The two systems were completely independent of each other.
The AI just had access to these GOAP structures but it had to determine what they meant and how to accomplish it. There was no actual 'do this' coded into the GOAP structures.
As for actually performing tasks you may benefit from looking into state machines. You may need to design multiple states to accomplish any one step.
I don't know if any of my rambling will help you, but here's hoping.
@Binsk How often should I use state machines? I haven't used them in Godot but I've seen people use them a lot more in Godot than in other engines such as Unity. Is there a reason for this?
State machines are the bread and butter of game AI. It would definitely be a good idea to start with that, as it is easy to reason with and follow the logic. You can also combine it with path finding and get reasonably smart looking AI even if it's all basically scripted.
- Edited
You might also want to look into behaviour trees.
edit: oh and decision trees.
- Edited
Is this a good general rule for when to use state-machines? "If it can move on it's own [players, enemies, cars, etc], it should use a state machine".
Also, are behavior trees and decision the same thing?
- Edited
The following is a pretty good basic explanation of the difference, IMO: https://gamedev.stackexchange.com/a/51722