Skip to content

Demonstration of Artificial Intelligence using Pac-man game

Notifications You must be signed in to change notification settings

ghoshavirup0/Pac-man

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pac-man

In this project I am going to illustrate the following using our beloved Pac-man game :
  1. Search algorithms (DFS, BFS, UCS, A*)

Instructions

Clone or download the entire package and follow instructions to run the program in your system. Make sure you have installed Python 3.7 or higher . To play the game just run the following command in command line:

python pacman.py

Visualizaton of Search algorithms (DFS, BFS, UCS, A*):

AI.Assignment.mp4

Pacman lives in a shiny blue world of twisting corridors and tasty round treats. Navigating this world efficiently will be Pacman's first step in mastering his domain.
Here Pacman agent will find paths through his maze world, both to reach a particular location and to collect food efficiently using following algorithms:

  1. Depth First Search
  2. Breadth First Search
  3. Uniformed Cost Search
  4. A* Search

The codes are present in the following python files:

  1. search.py : Where all of the search algorithms reside.
  2. searchAgents.py : Where all of the search-based agents reside.

The simplest agent in searchAgents.py is called the GoWestAgent, which always goes West (a trivial reflex agent). This agent can occasionally win:

python pacman.py --layout testMaze --pacman GoWestAgent

But, things get ugly for this agent when turning is required:

python pacman.py --layout tinyMaze --pacman GoWestAgent

The missions is to solve the problem not only for tinyMaze but for all the mazes:

  1. tinyMaze
  2. mediumMaze
  3. bigMaze

Use the following command to excecute the algorithms (DFS, BFS, UCS, A*) to solve the path finding problem for any kind of maze mentioned above. Just edit the maze name and fn value (i.e. dfs, bfs, ucs, astar).
Note: Heuristic is only used in case of A* algorithm
python pacman.py -l <maze name> -p SearchAgent -a fn=<dfs or bfs or ucs or astar> ,heuristic=manhattanHeuristic

Example: mediumMaze and bfs algorithm:

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

Use the following command for more complex problem (requires more computation) :

python pacman.py -l testSearch -p SearchAgent -a fn=astar, prob=FoodSearchProblem, heuristic=foodHeuristic