Skip to content

This project is based on the UC Berkeley CS188 Pacman AI framework, implementing and testing algorithms and multi-agent search strategies for Pacman.

License

Notifications You must be signed in to change notification settings

AthosExarchou/pacman-ai

Repository files navigation

Pacman AI – Search Algorithms

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.

Description

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.


Installation & Setup

1. Clone the repository

git clone https://github.com/AthosExarchou/pacman-ai.git
cd pacman-ai

2. Create and activate a Conda environment

conda create -n pacman-env python=3.6
conda activate pacman-env

3. Run the game

Example run using AlphaBetaAgent with custom evaluation:

python pacman.py -p AlphaBetaAgent -a evalFn=better,depth=2 -l smallClassic -k 2
pacman-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 files

Testing & Project Commands

Run Pacman in a medium maze with BFS search:

python pacman.py -l mediumMaze -p SearchAgent -a fn=bfs

Run Pacman in a medium maze with A* search:

python pacman.py -l mediumMaze -p SearchAgent -a fn=astar,heuristic=manhattanHeuristic

Run minimax:

python pacman.py -p MinimaxAgent -a evalFn=better,depth=2 -l smallClassic -k 2

Run alpha-beta pruning:

python pacman.py -p AlphaBetaAgent -a evalFn=better,depth=2 -l smallClassic -k 2

If you want to run the UC Berkeley autograder tests:

python autograder.py --no-graphics

Or test a single question (e.g. question-6):

python autograder.py -q q6

Author

License

This project is based on UC Berkeley CS188 Pacman framework. Original materials available here.

About

This project is based on the UC Berkeley CS188 Pacman AI framework, implementing and testing algorithms and multi-agent search strategies for Pacman.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages