Python · YOLOv5 · OpenCV · Pathfinding · Game AI
Pac-Man Pathfinding AI
A computer-vision control loop that detects a live Pac-Man screen, plans a path, and plays through keyboard input.
Project Goal
This project was built for an AI and Game Programming term project, where the goal was to apply YOLO-based object detection to a playable game-control problem.
- The project focused on connecting computer-vision output to actual game behavior, not just running object detection as a standalone demo.
- Pac-Man was a suitable target because the game state could be interpreted from visible objects such as the player, ghosts, edible ghosts, dots, and power pellets.
- The goal was to build an AI loop that reads the game screen, interprets the current state, and controls Pac-Man automatically.
Implementation
I led a 4-member team and implemented the AI control loop around object detection and pathfinding.
- Integrated a custom YOLOv5 object detector trained for Pac-Man objects, then mapped detected objects onto grid-cell coordinates.
- Built decision logic that updates game-state information per frame, selects a movement target, and runs A* pathfinding over non-wall grid cells.
- Connected the selected next move to keyboard-input events and OpenCV overlays, so the system could control Pac-Man while visualizing the chosen direction and path.
Result
The project produced a playable Pac-Man AI prototype for the term project.
- The final demo showed Pac-Man moving autonomously based on screen recognition rather than direct access to internal game-state data.
- The project demonstrated a complete applied-AI game loop from visual recognition to in-game control.
- As team lead, I integrated detection, decision-making, pathfinding, and control components into one working prototype.
