FSM – finitie state machine

A finite state machine. Something I’d never heard of. The task said that you should make three different AI-states for enemies, but it was not as simple as expected. We had three different states, but we had no state machine for it, so we couldn’t get points for that either.

We had to get points for that.

We made the state machine by making the enemy’s update-function into a small state manager that updated different states. The states were object that inherited from AI-state and they were all in a vector within the enemy. Our three states we used wre following: Idle, Chasing and Chilling.

The enemy started out as ”Idle”, moving back and forward across the screen. If the player got too close to the enemy it would enter the Chasing-state, starting to chase the player with accelerating speed. If you managed to dodge the enemy and it went outside a certain radius of you it would enter the Chilling-state. It would just stand completely still until you got close to it again. We were planning on making them fire lazers during the chilling state, but since we have so much to do we skipped that.

That was our cheap finite state machine. Hope that our teacher doesn’t hate it too much.