LtVaios / Berkeley-Pacman-Project

:ghost: :video_game: This is my implementation in the famous Berkeley pacman artificial intelligence project: http://ai.berkeley.edu/project_overview.html.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Berkeley Pacman Project

➡️ Official project website and documentation about it: http://ai.berkeley.edu/project_overview.html)

➡️ I used various algorithms explained below to make a pacman eat all the dots (project 1) by itself and also made more complex algorithms to make it play and win the game by itself ghosts included (project 2). These files also include a real pacman game version you can play in your terminal. The graphics and the game files needed to play the actual game are not implemented by me, I only implemented the AI algorithms. You can find more info about the project in the link above.

✏️ Inside each project folder you will also find some of mine documentation (in Greek) on how the functions work but there are also a lot of code comments.

Installation / run

🏁 Project-1

Download the folders and install them locally. You can run these commands on the terminal while being in the folder /search:

🔹 DFS (Depth-first-search) Algorithm:

  $ python pacman.py -l tinyMaze -p SearchAgent
  $ python pacman.py -l mediumMaze -p SearchAgent
  $ python pacman.py -l bigMaze -z .5 -p SearchAgent

🔹 BFS (Breadth-first-search) Algorithm:

  $ python pacman.py -l mediumMaze -p SearchAgent -a fn=bfs
  $ python pacman.py -l bigMaze -p SearchAgent -a fn=bfs -z .5

🔹 Solving the eightpuzzle which puts all numbers of a box in order, using BFS:

  $ python eightpuzzle.py

🔹 Implemented Uniform-Cost-Search function:

  $ python pacman.py -l mediumMaze -p SearchAgent -a fn=ucs
  $ python pacman.py -l mediumDottedMaze -p StayEastSearchAgent
  $ python pacman.py -l mediumScaryMaze -p StayWestSearchAgent

🔹 A* (A star) graph search Algorithm:

  $ python pacman.py -l bigMaze -z .5 -p SearchAgent -a fn=astar,heuristic=manhattanHeuristic

🔹 Data decoding of the corners problem and run with BFS:

  $ python pacman.py -l tinyCorners -p SearchAgent -a fn=bfs,prob=CornersProblem
  $ python pacman.py -l mediumCorners -p SearchAgent -a fn=bfs,prob=CornersProblem

🔹 Using A* to solve the corners problem but with a new heuristic implemented by me:

  $ python pacman.py -l mediumCorners -p AStarCornersAgent -z 0.5

🔹 Using A* to solve the corners problem:

  $ python pacman.py -l testSearch -p AStarFoodSearchAgent

🔹 Upgrade A* to make the pacman eat all the dots:

  $ python pacman.py -l trickySearch -p AStarFoodSearchAgent

🔹 Implementing a greedy algorithm that always eats the closest dot and it is the most efficient one for this problem.

  $ python pacman.py -l bigSearch -p ClosestDotSearchAgent -z .5 

👻 Project-2

Download the folders and install them locally. You can run these commands on the terminal while being in the folder /multiagents:

🔹 Reflex Agent:

  $ python pacman.py --frameTime 0 -p ReflexAgent -k 1
  $ python pacman.py --frameTime 0 -p ReflexAgent -k 2
  $ python autograder.py -q q1

🔹 Minimax algorithm:

  $ python pacman.py -p MinimaxAgent -l minimaxClassic -a depth=4
  $ python pacman.py -p MinimaxAgent -l trappedClassic -a depth=3
  $ python autograder.py -q q2

🔹 Alpha-Beta pruning algorithm:

  $ python pacman.py -p AlphaBetaAgent -a depth=3 -l smallClassic
  $ python pacman.py -p AlphaBetaAgent -l trappedClassic -a depth=3 -q -n 10
  $ python autograder.py -q q3

🔹 Expectimax algorithm:

  $ python pacman.py -p ExpectimaxAgent -l minimaxClassic -a depth=3
  $ python pacman.py -p ExpectimaxAgent -l trappedClassic -a depth=3 -q -n 10
  $ python autograder.py -q q4

🔹 Evaluation Function:

  $ python autograder.py -q q5

🎮 Play a game of pacman

  $ python pacman.py

Built With

MarineGEO circle logo

About

:ghost: :video_game: This is my implementation in the famous Berkeley pacman artificial intelligence project: http://ai.berkeley.edu/project_overview.html.

License:MIT License


Languages

Language:Python 100.0%