Adding behavioral movements
When we talk about AI in games, after pathfinding the next most important thing to consider is movement. When does an AI decide that it has to walk, run, jump, or slide? The ability to make these decisions quickly and correctly will make the AI really competitive in games and extremely difficult to beat. We can do all this with the help of behavioral movements.
Getting ready
For this recipe, you will need a Windows machine and Visual Studio. No other prerequisites are required.
How to do it…
In this example, you will find out how easy it is to create a decision tree. Add a source file called Source.cpp
and add the following code to it:
/* Adding Behavorial Movements*/ #include <iostream> using namespace std; class Machine { class State *current; public: Machine(); void setCurrent(State *s) { current = s; } void Run(); void Walk(); }; class State { public: virtual void Run(Machine *m) { cout << " Already Running\n"; } virtual...