Now that we have the tools we need in our Collider and Vector2D classes, we can build our FSM. The FiniteStateMachine class will manage our AI. Our FSM will have four states: SEEK, FLEE, ATTACK, and WANDER. It will implement steering behaviors and add an avoid force whenever it is trying to navigate through obstacles such as asteroids. The AI will also need to check whether the enemy ship should raise or lower its shields. Let's take a second look at the definition of the FiniteStateMachine class as we have defined it in our game.hpp file:
class FiniteStateMachine {
public:
const float c_AttackDistSq = 40000.0;
const float c_FleeDistSq = 2500.0;
const int c_MinRandomTurnMS = 100;
const int c_RandTurnMS = 3000;
const int c_ShieldDist = 20;
const int c_AvoidDist = 80;
const int c_StarAvoidDistSQ = 20000;
...