Académique Documents
Professionnel Documents
Culture Documents
UninformedSearch
Thecodeusedforthisassignmentisfromtheopencourse,CS188.1xArtificialIntelligence.
Coursewebsite:h ttp://ai.berkeley.edu/home.html.
Inthisassignmentyouwilldiscoverthedifferentbehaviorofthreesearchalgorithms:BFS,DFS
andUCSusingthepacmangame.Youneedtosubmitareportofyourobservation.
InvokingthePythonInterpreter
ThisclassassumeyouusePython2.7.Toseeifyouhavepythoninstalled,openterminalon
osx/linux,orcommandpromptonwindows,andinputcommand python
version .Ifyou
seethefollowingoutput,itmeanspythonhasbeeninstalledonyoursystem.
$
python
version
Python
2.7.13
Otherwise,youneedtofollowtheseinstructions:
Windows:
a. Downloadpythonwindowsinstallerath ttps://www.python.org/downloads/
b. Runtheinstaller,choosethelocationwhereyouwanttoinstallPython,for
exampleC :\Python27\
c. SetthesystemsPATHvariable
i. OpentheControlPanel(easyway:clickintheWindowssearchonyour
taskbarandtypeControlPanelthenclicktheicon).
ii. IntheControlPanel,searchforEnvironmentclickEdittheSystem
EnvironmentVariables.ThenclicktheEnvironmentVariablesbutton.
iii. IntheUserVariablessection,youwillneedtoeithereditanexistingPATH
variableorcreateone.Addthisline
C:\Python27;C:\Python27\Lib\sitepackages\;C:\Python27\Scri
pts\
toPATH,
1. Ifyouarecreatingone,makePATHthevariablenameandadd
thefollowingdirectoriestothevariablevaluessectionasshown,
separatedbyasemicolon.
2. IfyoureeditinganexistingPATH,thevaluesarepresentedon
separatelinesintheeditdialog.ClickNewandaddonedirectory
perline.
OSX:h ttp://docs.pythonguide.org/en/latest/starting/install/osx/
ThePackmanProgram
Downloada ssignment1.zip o
ncanvas,unzipthefilestoa
ssignment1
.Usec
d
commandto
changetoourworkingdirectory.
$
unzip
assignment1.zip
$
c
d
assignment1
$
ls
Someusefulterminalcommands
Forbash(osx/linux)
https://www.gittower.com/learn/git/ebook/en/commandline/appendix/commandline101
Forwindowscommandprompt
http://www.cs.princeton.edu/courses/archive/spr05/cos126/cmdprompt.html
Herestheoverviewoffilesinthepackage,youdontneedtoreadthemforcompletingthis
assignment.
Filesyoumaywanttoread.
search.py Allofthesearchalgorithms.
searchAgents.py Allofthesearchbasedagentsinteractwiththegameworld.
Supportingfilesyoucanignore:
ThemainfilethatrunsPacmangames.Thisfiledescribesa
pacman.py PacmanGameStatetype,whichyouuseinthisproject.
ThelogicbehindhowthePacmanworldworks.Thisfile
describesseveralsupportingtypeslikeAgentState,Agent,
game.py Direction,andGrid.
util.py Usefuldatastructuresforimplementingsearchalgorithms.
graphicsDisplay.py GraphicsforPacman
graphicsUtils.py SupportforPacmangraphics
textDisplay.py ASCIIgraphicsforPacman
ghostAgents.py Agentstocontrolghosts
keyboardAgents.py KeyboardinterfacestocontrolPacman
layout.py Codeforreadinglayoutfilesandstoringtheircontents
Usecommandp
ython
torunaninteractivepacmangame.
pacman.py
Youcanuseoptionstospecifysearchalgorithmandmaplayout
$
python
pacman.py
p
SearchAgent
a
fn=bfs,prob=FoodSearchProblem
l
testMaze
Heressomeoftheusefulargumentdefinitions
l,layout choosethemapforthisgame.
p,pacman choosethepacmantype,itcanbefixedasSearchAgent
Commaseparatedvaluessenttoagent.There'sthree
a,agentArgs argumentsforSearchAgent
fn:searchfunction,youcanchoosefrombfs(breadthfirst
search)dfs(depthfirstsearch)orucs(uniformcostsearch)
prob:problemtype.Inthisassignment,youneedtouse
FoodSearchProblem
heuristic:choosetheheuristicfunction,nousefornow.
Foruniformcostsearch,thecostissetasdepthofthesearchtree.
Youcanalsodrawyourownmapbyimitatingtheexistingones,putitunderlayoutsdirectory
andhavefun.
$
python
pacman.py
h
Task:Rundifferentprogramsettingsandsubmita
report
Inthisassignment,youneedtochooseatleastthreedifferentlayouts,foreachlayoutrunthree
differentalgorithms:dfs,bfsanducs.Writeareportaboutthedifferencebetweeneach
algorithm,includingthepathsearchedbytheagent,searchnodesexpanded,timecostandetc.
Pleasewriteandsubmityourreportoncanvas.
Ifyouhaveanyquestion,feelfreetocontactTA,YanLiangy liangav@connect.ust.hk.