PacMaze
PacMaze
![]()
Introduction
PacMaze is a game independently developed by WaterCoFire for the DIICSU DI32002 - Games Programming module assignment. Fortunately, it helped WaterCoFire achieve his first overall grade A1 in DIICSU professional course.
In this game, you need to control Pacboy to eat all the dots in a complex maze while avoiding the hungry Ghostrons who are looking for you as their main course for their dinner party!
Inspired by the Pac-Man game (Namco, 1980), while retaining many classic elements, PacMaze introduces a large number of original elements:
- 3D Gaming
- Switching between TPV and FPV
- Map Editor for customising your ideal map, from difficulty to wall layout
- Plenty of original props that grant various strategic abilities
- Random events that add fun and unpredictability (free to choose to enable or not!)
Map Overview
This diagram introduces all the elements that appear in a typical PacMaze game map (11×11).
If you are a DIICSU Comp Sci student
This diagram is not a correct submission example of the “Game Map Sketch” section of Assignment 1 in the DI32002 - Games Programming module, as it does not illustrate all of the information required for that section. This diagram is only a portion of the original image took from my own submission.

Game Screenshot (Examples)
Home Page

Map Select Page

Gameplay (in TPV)

Map Editor

Algorithms & Techniques
PacMaze has some cool built-in algorithms and techniques, including:
Finite State Machine (FSM) for Ghostrons
FSM is used for Ghostron behaviours for it provides a clean and well-structured way to handle Ghostron’s states (Chase, Normal Wander, Scared Wander, Stall), each with its own logic and transitions.
Unique Personalities & Behaviours for Different Types of Ghostron
To enhance the playability of the game, inspiration is taken from the classic Pac-Man game (Namco, 1980): Different types of Ghostron are designed to have different personalities, i.e., different behaviours.
For example, Blue Ghostrons are “introverted”, Yellow Ghostrons are “curious”, Green Ghostrons are “sensitive”.
Improved Distribution Algorithm and Braid Algorithm
As most classic maze generation algorithms can’t avoid generating dead ends, PacMaze took inspiration from the Distribution Algorithm and Braid Algorithm by Ioannidis (2016), which are capable of generating Braid Mazes. Braid Mazes refer to mazes with no dead ends (Hybesis - H.urna, 2019).
The Distribution Algorithm generates a distribution matrix determining the number of neighbours for each tile, and the Braid Algorithm generates the maze based on the distribution matrix.
In order to make the generated map more playable and suitable for PacMaze, many improvements are made based on the original scheme. Through the analysis, four patterns of a PacMaze map are summarised by WaterCoFire, and the Distribution Algorithm is optimised accordingly so that the neighbour distribution matrix it generates conforms to the law. The Braid Algorithm has also been optimised by WaterCoFire in that it no longer relies solely on random logic, but instead treats tiles differently based on their location as well as their number of neighbours distributed.
This improvement ensures that the final generated maps can have designed characteristics and provide better playability than random generation.
Click here to learn more about the details of the algorithm scheme improvement.
Modified Breadth First Search (BFS) for Map Legality Check
To ensure game experience, a valid PacMaze map must fulfil the following rules:
- Reachability. Each tile on the map must be reachable.
- Ease of Reachability. The player’s path from the centre of the map to each tile must not be too long, and the shortest path length (from the centre) for all tiles should be less than or equal to 22 tiles.
- No Dead Ends. That is, there should not be a tile with no walls on only one side. This does not mean that all tiles should have more than two walls, given the existence of boundaries.
BFS is used for legality checking as it is ideal for shortest path discovery and reachability analysis. As BFS does not directly identify dead ends, a small modification is made: the number of neighbours of each traversed tile will be checked. If it is one-neighbour, then it is considered a dead-end.
Mouse Position Detection & Highlight Interaction
In order to provide a more intuitive experience in the Map Editor, in some edit modes, the current mouse position needs to be checked in order to achieve highlighting effect. This gives players real-time feedback. In the process, Unity’s Raycast system is used for detecting mouse ray collisions with game objects.
Secure Save/Read of Map Data
All the map settings can be stored as a JSON file to ensure map data persistence. This allows players to preserve their custom maps and settings, and ensures that they can reload and edit/play their customised creations at any time.
To prevent malicious players from cheating by tampering with map data, an AES encryption algorithm with random Initialisation Vectors (IVs) is also used to encrypt/decrypt map data.
Accessing
The PacMaze project (including source code) has been open-sourced on GitHub.
For reference only. Please consciously refrain from all infringement of others’ IP rights as well as academic misconduct.
This project will be maintained (occasionally). The latest release is v1.1.0.
References
This reference list is in Harvard style.
Hybesis - H.urna. (2019) Maze generations: Algorithms and Visualizations. Analytics Vidhya. Available at: https://medium.com/analytics-vidhya/maze-generations-algorithms-and-visualizations-9f5e88a3ae37 (Accessed: 4 May 2025).
Ioannidis P.L. (2016) Procedural Maze Generation. Bachelor Thesis. National and Kapodistrian University of Athens. Available at: https://pergamos.lib.uoa.gr/uoa/dl/object/1324569/file.pdf (Accessed: 6 May 2025).
Namco. (1980) Pac-Man [Video game]. Bandai Namco Entertainment, Arcade.
All third-party graphics/audio resources used in PacMaze (and their licences) can be found in the README in the GitHub repository of this project.
