This project was developed for the Artificial Intelligence course at Harokopio University of Athens – Dept. of Informatics and Telematics. It is based on the UC Berkeley CS188 Pacman AI framework, implementing and testing search algorithms and multi-agent search strategies for Pacman.
Pacman is controlled by an AI agent that makes decisions based on:
- The distance to the nearest ghost
- The distance to the nearest food
- The current score (number of food pellets eaten)
- The remaining food
The main custom code is implemented in search.py, searchAgents.py and multiAgents.py.
git clone https://github.com/AthosExarchou/pacman-ai.git
cd pacman-aiconda create -n pacman-env python=3.6
conda activate pacman-envExample run using AlphaBetaAgent with custom evaluation:
python pacman.py -p AlphaBetaAgent -a evalFn=better,depth=2 -l smallClassic -k 2pacman-ai/
│── pacman.py # Main entry point
│── multiAgents.py # Contains custom evaluation function
│── search.py # Search algorithms
│── searchAgents.py # Search agent definitions
│── util.py # Helper functions
│── game.py, ghostAgents.py # Core game logic
│── graphicsDisplay.py # Graphics rendering
│── graphicsUtils.py
│── layouts/ # Maze layout files
│── README.md # This file
│── .gitignore # Ignored filesRun Pacman in a medium maze with BFS search:
python pacman.py -l mediumMaze -p SearchAgent -a fn=bfsRun Pacman in a medium maze with A* search:
python pacman.py -l mediumMaze -p SearchAgent -a fn=astar,heuristic=manhattanHeuristicRun minimax:
python pacman.py -p MinimaxAgent -a evalFn=better,depth=2 -l smallClassic -k 2Run alpha-beta pruning:
python pacman.py -p AlphaBetaAgent -a evalFn=better,depth=2 -l smallClassic -k 2If you want to run the UC Berkeley autograder tests:
python autograder.py --no-graphicsOr test a single question (e.g. question-6):
python autograder.py -q q6- Name: Exarchou Athos
- Student ID: it2022134
- Email: [email protected] or [email protected]
This project is based on UC Berkeley CS188 Pacman framework. Original materials available here.