Answered step by step
Verified Expert Solution
Question
1 Approved Answer
modify search.py and searchagent.py in pyhton for dfs , bfs , uniform search, nullheurstic, a * and cornersproblem In this lab, your Pacman agent will
modify search.py and searchagent.py in pyhton for dfsbfs uniform search, nullheurstic, a and cornersproblem
In this lab, your Pacman agent will find paths through his maze world, both to reach a
particular location and to collect food efficiently. You will build general search
algorithms and apply them to Pacman scenarios.
This lab includes an autograder for you to grade your answers on your machine. This
can be run with the command:
python autograder.py
The code for this lab consists of several Python files, some of which you will need to
read and understand in order to complete the assignment, and some of which you can
ignore. You can download all the code and supporting files as a zip archive searchzip
Files you'll edit:
search.py Where all of your search algorithms will reside.
searchAgents.py Where all of your searchbased agents will reside.
Files you might want to look at:
pacman.py
The main file that runs Pacman games. This file describes a Pacman
GameState type, which you use in this lab.
game.py
The logic behind how the Pacman world works. This file describes
several supporting types like AgentState, Agent, Direction, and Grid.
util.py Useful data structures for implementing search algorithms.
Supporting files you can ignore:
graphicsDisplay.py Graphics for Pacman
graphicsUtils.py Support for Pacman graphics
textDisplay.py ASCII graphics for Pacman
ghostAgents.py Agents to control ghosts
keyboardAgents.py Keyboard interfaces to control Pacman
layout.py Code for reading layout files and storing their contents
autograder.py Lab autograder
testParser.py Parses autograder test and solution files
testClasses.py General autograding test classes
testcases Directory containing the test cases for each question
searchTestClasses.py Lab specific autograding test classes
Files to Edit and Submit: You will fill in portions
of search.py and searchAgents.py during the assignment. You should submit these files
with your code and comments. Please do not change the other files in this distribution
or submit any of the original files other than these files.
Evaluation: Your code will be autograded for technical correctness. Please do not
change the names of any provided functions or classes within the code, or you will
wreak havoc on the autograder. However, the correctness of your implementation not
the autograders judgements will be the final judge of your score.
Academic Dishonesty: We will be checking your code against other submissions in the
class for logical redundancy. If you copy someone elses code and submit it with minor
changes, we will know. These cheat detectors are quite hard to fool, so please dont try.
We trust you all to submit your own work only; please dont let us down. If you do we
will pursue the strongest consequences available to us
Discussion: You can use the Discussion page set up for this lab to inquire and get
clarifications, but please be careful not to post spoilers.
Welcome to Pacman
After downloading the code, unzipping it and changing to the directory, you should be
able to play a game of Pacman by typing the following at the command line:
python pacman.py
Pacman lives in a shiny blue world of twisting corridors and tasty round treats.
Navigating this world efficiently will be Pacmans first step in mastering his domain.
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
If Pacman gets stuck, you can exit the game by typing CTRLc into your terminal.
Soon, your agent will solve not only tinyMaze, but any maze you want.
Note that pacman.py supports a number of options that can each be expressed in a long
way eglayout or a short way egl You can see the list of all options and their
default values via:
python pacman.py h
Also, all of the commands that appear in this lab also appear in commands.txt for easy
copying and pasting. In UNIXMac OS X you can even run all these commands in order
with bash commands.txt
Q pts: Finding a Fixed Food Dot using Depth First
Search
In searchAgents.py youll find a fully implemented SearchAgent, which plans out a path
through Pacmans world and then executes that path stepbystep. The search
algorithms for formulating a plan are not implemented thats your job.
First, test that the SearchAgent is working correctly by running:
python pacman.py l tinyMaze p SearchAgent a fntinyMazeSearch
The command above tells the SearchAgent to use tinyMazeSearch as its search algorithm,
which is implemented in search.py Pacman should navigate the maze successfully.
Now its time to
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started