A proof of concept 2D game developed in Python with Pygame. This project demonstrates the implementation of the Breadth First Search (BFS) algorithm to create a dynamic pathfinding AI for a zombie horde that chases the player on a grid-based map with randomly generated obstacles.

The goal of this project is to be a practical demonstration of how graph transversal algorithms can be applied to solve complex AI navigation problems in real-time. The simulation creates an environment where a user-controlled player must survive against zombies that use BFS to calculate the shortest path to the player while avoiding obstacles.
The game features player movement, with WASD keys, AI with BFS pathfinding, random obstacle generation and state management with game over condition.
- Graph data structure: The map is represented as a graph, where each tile is a node and adjacent connections are the edges.
- BFS Algorithm: Used to calculate the shortest path from a zombie to the player.
- Game AI: Reactive AI based on perception (player's position) and navigation (pathfinding).
- Game Loop and Event Handling: Usage of the main Pygame loop to process user input, update game logic, and render graphics each frame.
- Python 3;
- pip (Python package manager).
- Clone the repo:
git clone https://github.com/yanrdgs-dev/bfs-horde.git- Navigate to the project directory:
cd bfs-horde- Install the pygame library:
pip install pygameTo start the game, run the main file:
python game.pyTo play, use the WASD keys to move, and run from the zombies for as much time as possible while avoiding the obstacles.
For future improvements, it would be nice to implement the A* (A-Star) algorithm and compare its performance with BFS, and to add a scoring system. Also, improving the graphics would be nice (not a main priority, though).
After implementing, it was clear that the implementation was slow. If there isn't a cooldown on player movement, it doesn't even give the program enough time to process the pathfinding and move the zombies.
Contribution is welcome! Contribute through an issue or an pull request.