Enums and Enemy AI

Let’s make a FSM — finite state machine using an Enum (usually with switch statements). Let’s start by creating our enemy state enum.

Let’s begin and have our enemy start the game in a patrolling state.

Let’s create a switch statement that uses the parameter currentstate to cycle through the enemy states.

To make the enemies freak out and go on attack, we can test a change in the current state.