Finite State Machine


Overview:

In this simple game, the player's objective is to escape from the enemy. The enemy's behavior is governed by a finite state machine, which controls its actions and decision-making process. Additionally, the enemy utilizes the A* algorithm for movement, enabling it to navigate the game environment effectively. The combination of the finite state machine and A* algorithm ensures that the enemy dynamically responds to the player's movements and attempts to capture them.

  • Solo project
  • Finite state machine
  • A* algorithm
  • Procedural generation

Completion: November 2022

Duration: 1 day

Platform: Unity 2D


Contribution:

Finite State Machine

This project's primary emphasis was on implementing a finite state machine. The game revolves around the player moving around and evading the enemy. The enemy, controlled by its own finite state machine, exhibits behavior aimed at capturing the player. Additionally, the enemy employs raycasts to detect the player's presence. When chasing the player, the enemy gets bored after some time.

Movement

For moving around, the player and the enemy employ distinct methods for movement. The player utilizes user input to navigate in four directions across the map, allowing for flexible movement. On the other hand, the enemy employs the A* algorithm and a node-based system to navigate the map. This algorithm enables the enemy to find the optimal path while avoiding walls, creating intelligent and obstacle-aware movement. Both the player and the enemy can freely move around the map within the constraints of the game's environment, ensuring engaging gameplay while preventing passage through walls.

Map

The map was designed using some tiles. Using the editor you can choose the size you want for the map and the map is generated according to the selected size. The walls are added procedurally to give a different layout to the map every time.


closing thougths:

This project provided an opportunity to explore the implementation of a finite state machine and the integration of the A* algorithm for enemy movement. The combination of these two components created a dynamic and challenging gameplay experience where the player must evade the enemy's pursuit. The procedural generation of the map added variety and replayability to the game. Overall, this project allowed for the development of essential AI and game design skills.