COMP3411ArtificialIntelligence
Session1,2017
Project3,Option1:TreasureHunt
Due:Sunday28May,11:59pm
Marks:18%offinalassessment
Forthisprojectyouwillbeimplementinganagenttoplayasimpletextbasedadventure
game.Theagentisconsideredtobestrandedonasmallgroupofislands,withafewtreesand
theruinsofsomeancientbuildings.Itisrequiredtomovearoundarectangularenvironment,
collectingtoolsandavoiding(orremoving)obstaclesalongtheway.
Theobstaclesandtoolswithintheenvironmentarerepresentedasfollows:
ObstaclesTools
T tree a axe
door k key
* wall d dynamite
~ water $ treasure
Theagentwillberepresentedbyoneofthecharacters^,v,<or>,dependingonwhich
directionitispointing.Theagentiscapableofthefollowinginstructions:
Lturnleft
Rturnright
F(tryto)moveforward
C(tryto)chopdownatree,usinganaxe
B(tryto)blastawallortree,usingdynamite
WhenitexecutesanLorRinstruction,theagentremainsinthesamelocationandonlyits
directionchanges.WhenitexecutesanFinstruction,theagentattemptstomoveasinglestep
inwhicheverdirectionitispointing.TheFinstructionwillfail(havenoeffect)ifthereisa
wallortreedirectlyinfrontoftheagent.
Whentheagentmovestoalocationoccupiedbyatool,itautomaticallypicksupthetool.The
agentmayuseaC,UorBinstructiontoremoveanobstacleimmediatelyinfrontofit,ifitis
carryingtheappropriatetool.AtreemayberemovedwithaC(chop)instruction,ifanaxeis
held.AdoormayberemovedwithaU(unlock)instruction,ifakeyisheld.Awall,treeor
doormayberemovedwithaB(blast)instruction,ifdynamiteisheld.
Wheneveratreeischopped,thetreeautomaticallybecomesaraftwhichtheagentcanuseasa
tooltomoveacrossthewater.Iftheagentisnotholdingaraftandmovesforwardintothe
water,itwilldrown.Iftheagentisholdingaraft,itcansafelymoveforwardintothewater,
andcontinuetomovearoundonthewater,usingtheraft.Whentheagentstepsbackontothe
land,theraftitwasusingwillsinkandcannotbeusedagain.Theagentwillneedtochop
downanothertreeinordertogetanewraft.
Iftheagentattemptstomoveofftheedgeoftheenvironment,itdies.
Towinthegame,theagentmustpickupthetreasureandthenreturntoitsinitiallocation.
RunningasaSingleProcess
Copythearchivesrc.zipintoyourownfilespaceandunzipit.Thentype
cdsrc
javac*.java
javaRaftis0.in
Youshouldthenseesomethinglikethis:
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~~d*Ta~~
~~*****~~
~~****v****~~
~~TTT****TTT~~
~~$**k**~~
~~****~~
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
EnterAction(s):
Thisallowsyoutoplaytheroleoftheagentbytypingcommandsatthekeyboard(followed
by
akeycanbeusedtounlockanydooronceitisunlocked,ithaseffectivelybeen
removedfromtheenvironmentandcanneverbeclosedagain.
anaxeorkeycanbeusedmultipletimes,buteachdynamitecanbeusedonlyonce.
theagentcanholdmultipledynamitessimultaneously,butitcanonlyholdoneraftata
time.
C,UorBinstructionswillfail(havenoeffect)iftheappropriatetoolisnotheld,orifthe
locationimmediatelyinfrontoftheagentdoesnotcontainanappropriateobstacle.
RunninginNetworkMode
Followtheseinstructionstoseehowthegamerunsinnetworkmode:
1.opentwowindows,andcdtothesrcdirectoryinbothofthem.
2.chooseaportnumberbetween1025and65535letssupposeyouchoose31415.
3.typethisinonewindow:
javaRaftp31415is0.in
4.typethisintheotherwindow:
http://www.cse.unsw.edu.au/~cs3411/17s1/hw3raft/src.zip
javaAgentp31415
Innetworkmode,theagentrunsasaseparateprocessandcommunicateswiththegame
enginethroughaTCPIPsocket.Noticethattheagentcannotseethewholeenvironment,but
onlya5by5windowarounditscurrentlocation,appropriatelyrotated.Fromtheagents
pointofview,locationsofftheedgeoftheenvironmentappearasadot.
WehavealsoprovidedaCversionoftheagent,whichyoucanrunbytyping
make
./agentp31415
WritinganAgent
Ateachtimestep,theenvironmentwillsendaseriesof24characterstotheagent,constituting
ascanofthe5by5windowitiscurrentlyseeingtheagentmustsendbackasinglecharacter
toindicatetheactionithaschosen.
Youarefreetowritetheagentinanylanguageyouchoose.IfyouarewritinginJava,your
mainfileshouldbecalledAgent.java(youarefreetousethesuppliedfileAgent.javaasa
startingpoint).IfyouarewritinginC,youarefreetousethefilesagent.c,pipe.candpipe.h
asastartingpoint.Inotherlanguages,youwillhavetowritethesocketcodeforyourself.You
mustincludeaMakefilewithyoursubmission,producinganexecutablecalledagent.
Youmayassumethatthespecifiedenvironmentisnolargerthan80by80,buttheagentcan
beginanywhereinsideit.
Additionalexamplesofinputandoutputfileswillbeprovidedinthedirectory
hw3raft/sample.
ThereisawidgetonthecourseWebsitewhichallowsyoutoedityourowninputmaps,test
themusingagraphicalinterface.andsharethemwithothers.
Question
Atthetopofyourcode,inablockofcomments,youmustprovideabriefanswer(oneortwo
paragraphs)tothisQuestion:
Brieflydescribehowyourprogramworks,includinganyalgorithmsanddata
structuresemployed,andexplainanydesigndecisionsyoumadealongtheway.
Submission
COMP3411studentsshouldsubmitbytyping
givecs3411hw3raftMakefile
COMP9414/9814studentsshouldsubmitbytyping
givecs9414hw3raftMakefile
http://www.cse.unsw.edu.au/~cs3411/17s1/hw3raft/sample
Youcansubmitasmanytimesasyoulikelatersubmissionswilloverwriteearlierones.You
cancheckthatyoursubmissionhasbeenreceivedbyusingoneofthesecommands:
3411classruncheck
9414classruncheck
ThesubmissiondeadlineisSunday28May,11:59pm.
15%penaltywillbeappliedtothe(maximum)markforevery24hourslateafterthedeadline.
QuestionsrelatingtotheprojectcanbepostedtotheForumsonthecourseWebsite.
IfyouhaveaquestionthathasnotalreadybeenansweredontheForum,youcanemailitto
[email protected]
PleaseensurethatyousubmitthesourcefilesandNOTanybinaryfiles.Thegivesystemwill
compileyourprogramusingyourMakefileandcheckthatitproducesabinaryfile(orjava
classfiles)withthecorrectname.
Assessment
Yourprogramwillbetestedonaseriesofsampleinputswithsuccessivelymorechallenging
environments.Therewillbe:
12marksforfunctionality(automarking)
6marksforAlgorithms,Style,CommentsandanswertotheQuestion
Youshouldalwaysadheretogoodcodingpracticesandstyle.Ingeneral,aprogramthat
attemptsasubstantialpartofthejobbutdoesthatpartcorrectlywillreceivemoremarksthan
oneattemptingtodotheentirejobbutwithmanyerrors.
PlagiarismPolicy
Yourprogrammustbeentirelyyourownwork.Plagiarismdetectionsoftwarewillbeusedto
compareallsubmissionspairwise(includingsubmissionsforanysimilarprojectsfrom
previousyears)andseriouspenaltieswillbeapplied,particularlyinthecaseofrepeat
offences.
DONOTCOPYFROMOTHERSDONOTALLOWANYONETOSEEYOUR
CODE
PleaserefertotheUNSWPolicyonAcademicHonestyandPlagiarismifyourequirefurther
clarificationonthismatter.
Goodluck!
https://student.unsw.edu.au/plagiarism
Reviews
There are no reviews yet.