WELCOME
Welcome visitors to your site with a short, engaging introduction. Double click to edit and add your own text.
ITS A
MAZE
Its A Maze is a chase game set in a labyrinth. The player must collect all the dots before they are caught. I created this game in Unity after writing A* and HPA* pathfinding algorithms. This game was the application of A* to test how well I'd written it and to see it working in a dynamic environment.
The code is available here:
https://github.com/dtocomerford/ai_in_games/tree/main
Features
Some areas I am most proud of in this project:
AI
The enemies are powered by the A* pathfinding algorithm, one of the most popular and efficient pathfinding algorithms.
Retro Controls
The user controls closely match the control scheme of the original Pac-Man.
State Machine
The AI is control by a state machine. The enemies have multiple phases of behaviour which are triggered and transitioned to via the state machine.
AI
A* Algorithm:
I implemented the A* algorithm for the enemy agents to chase the player. The algorithm uses a heuristic which provides an estimate of the distance from a given node to the end goal. This makes its behaviour informed, quicker and more efficient than an uninformed algorithm such as Dijkstra's. When the algorithm is evaluating nodes the heuristic score given to each node is considered and the node with the lowest score is selected to visit next. The algorithm stores nodes of the world map in two lists, the open and closed list. The open list stores nodes that have been discovered but not evaluated while the closed list stores nodes that have been visited or evaluated.
States:
The AI in the game is run using a state machine. I implemented a state machine to control the different behaviours of the enemies. The states which the enemies can exhibit are chase, scatter and scared. These behaviours are taken from the original Pac-Man. The chase state sets the enemy's target node as the one the player is currently on thus chases the player. The scatter state picks a node at random for the enemy to move to. The scared state will pick the node furthest away from the player and travel there. The states transition by triggers. The scared state is activated if the player picks up a fruit, the scared states duration is set on a timer which when reaches zero will trigger another change in state.