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
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:
- Depth First Search
- Breadth First Search
- Uniformed Cost Search
- A* Search
The codes are present in the following python files:
search.py
: Where all of the search algorithms reside.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:
tinyMaze
mediumMaze
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