COMP424Artificial intelligence

COMP424Artificial intelligence
WeChat:yj4399_
Sina Visitor System
COMP 424 Final ProjectGame:Colosseum Survival!CourseInstructor:JackieCheung and Bogdan MazoureProjectTAs:Koustuv Sinha ([email protected])and Shuhao Zheng([email protected])Due Date:April8th,2022,11:59PM EST1.GoalThe main goal of theprojectforthiscourse isto giveyou a chance to play around with someof the AI algorithms discussed in class,in the contextof a fun,large-scale problem.This yearwe willbe working on a game calledColosseum Survival!(https://github.com/Ctree35/Project-COMP424-2022-Winter).KoustuvSinhaandShuhaoZhengareinchargeoftheproject,andshouldbecontacteddirectlyaboutanybugsintheprovidedcode.GeneralquestionsshouldbepostedinEd.Thisisagroupproject,withtwostudentspergroup.2.Game Description andRulesColosseumSurvival!isa2-playerturn-basedstrategygameinwhichtwoplayersmoveinanM×Mchessboardand putbarriersaround them untilthey areseparatedintwo closedzones.Mcan have avaluebetween 4 and 10.Each playerwilltrytomaximize the numberofblocksinitszonetowin thegame.Figure1:Gameboard2.1SetupAtfirst,playersA andBarerandomlypositionedonthechessboardsymmetrically.Thetwoplayerswilltaketurnstomoveinthechessboardandputbarriers.Ineachturn,oneplayerwillmoveatmostKstepsandmustputa barrierinone of the4directionsaround

  1. itself attheend of moving.Here,Kiscomputed as (M+ 1)/2,which definesthemaximumnumberofallowablesteps.Eachstepcanonlybemadehorizontallyorvertically.Oneplayercannotgointotheother’sposition,gothroughthebarriers,orputbarriersinplacesthatalreadyhavebarriers(includingthegame borders).To increasetherandomness of thegame,K∗2barrierswillbeinitiallyputonthechessboardinasymmetrically.2.2ObjectiveThe game ends when two players are separated into two closed zones by barriers and borders.The finalscoreof eachplayer isthenumber of blocks in itszone in the endgame.The playerwiththehigherscorewillwin thegame,and willbeawarded 1point.Ifthereisatie,bothplayerswillbe awarded0.5points.An examplegameplayisshown inFigure2.2.3PlayingthegameForeachstep,themoveconsistsofprovidingan(x,y)co-ordinateof theboardwheretheplayerwantstogo,andadirection(up/down/left/right)theplayerwantstoputawall.Thenumberofstepstakentogotoposition(x,y)willbeautomaticallycomputedbythegame engineusingabreadth-first-searchalgorithm,andifthestepsaremorethanKthenerrorswillbeshown.2.4EvaluationInthefirstroundoftheevaluation,wewillholdacompetitionwhereeverysubmittedprogramwillbeplayingonematchagainstarandomsubsetofallsubmissions.Duetothedeterministicnatureofthegameboard,eachmatchwillconsistofNgames,givingboth programsequalopportunity toplayfirst(typicallyN >1000).Forthesecondround,the10percenthighestscoringagentsfromthefirstgamewillplayagainsteachotherintheplayofroundwhereeachagentispairedagainstallotheragentstofindthehighestscoringagents.The evaluationphasewillrequirealotofmatchessopleasebemindfulofyourprogram’sruntime.We willperformascreeningprocessbypairingyouragentwitharandomagenttoensuretheruntimesmatchestheexpectations(checktheTournamentConstraintsinSection5.1.1).3.AssignmentDetailsInthisfinalproject,your task istodevelop anagenttoplaytheColosseum Survivalgame.We havedevelopedaminimalisticgameengineinPython,whichyouwillextendtoaddyourownagents.3.1Pre-requirementsThis projectyou will need toimplement agent thatplayes Colosseum Survival using Python.Specifically,we strongly recommend to brush up Python 3 fundamentals before writing yourcode.We would also requireyou to knowgitfundamentals to work with theversion controlsystem,andhavean accountinGithub.2

  2. COMP424Artificial intelligence_第1张图片

    FinalprojectCOMP 424,McGillUniversity0123Y Position3210XPositionABA: HumanAgentB: HumanAgentMax steps: 2(a)Step00123Y Position3210XPositionABA: HumanAgentB: HumanAgentScores: A: [16], B: [16]Max steps: 2(b)Step10123Y Position3210XPositionABA: HumanAgentB: HumanAgentScores: A: [16], B: [16]Max steps: 2(c)Step20123Y Position3210XPositionABA: HumanAgentB: HumanAgentScores: A: [9], B: [7]Player A wins!Max steps: 2(d)Step3Figure2:A samplegame between two agents(AandB)on a4x4chessboard,thushavingmax allowablestepsK= 2.Theboardisinitialized(Step0)withrandom(symmetrical)wallplacements.A thenmovestoposition(1,1)andplacesawallonthetop(Step1).Bremainsinthesame position(2,1)and placesawallon theright(Step2).A thenwinsthegame by staying inthesame position(1,1)and placinga wallondown,thushaving controlof9blocksintheboard(Step3).3.2Working with GithubClassroomsForthepurposesof thisproject,wewillbeusingGithubClassrooms.GithubClassroomsallowustoeasilysharethetemplate repository andcreateprivaterepositoriesforstudents.To startworkinginyourassignment:•Accept this invitation (https://classroom.github.com/a/dRpR9fvL)to be addedtoourCOMP 424GithubClassroom.PleaseregisteryourteambyMarch11th,Friday.•Choose orcreateyourteam.Teamscanbe formedonlywithtwomembers.3

  3. COMP424Artificial intelligence_第2张图片

    •Once you accepttheassignment,yourcoderepositorywillbe setupusingthestartercode.•Inyour repository,a PullRequest(PR)would be automatically created,which wouldserveasa way to communicate with the TAs about specific,privateconcerns regardingyourcodeortogetfeedback.Alternatively,you cancontacttheTAs involvedinthisprojectdirectly.•Cloneyourassignedrepositorytostartworkingon theassignment1.•Navigatetothecloneddirectoryandinstallthedependencies:pipinstall-rrequirements.txt•To testthateverything runs on yourmachine as required,run thefollowing commandinthecloneddirectory:pytest3.3Implementingyourown agentYou need towriteyour ownagentand submititfortheclassproject.DetailedinstructionsofvariouspartsofthegameisavailableintheREADME.mdfile.Followthestepstoimplementandtestyourown agent:•Modify thestudentagent.pyfileinagents/directory,which extends theagents.Agent(inagents/agent.py)class.•Implementthestepfunctionwithyourgame logic•Registeryouragentusingthedecoratorregisteragent.TheStudentAgentclassisalreadydecoratedwith thename“studentagent”,feelfreetochangeitorkeepitthesame.•Importyouragentintheinit.pyfileinagents/directory.ThisstepisalreadydoneforStudentAgent.•Run and testyouragentusingsimulator.pyscript.Important:You should notmodify any other filesapartfromstudentagent.pyand anyhelperfileyouneedshouldalsobecreatedwithinagents/directory.Intheeventofanyupdate to the game code,the TAs will announce the necessary steps in Ed to pull the startercode.3.4PlaywithyouragentYoucanusethesimulator.pyscripttorunaninteractivesessionwithyouragent!AHuman agent(yourself)isdefinedinagents/directory,alongwitharandomwalkagent.You can firstvisualizethegame happening between thetwoagentsasfollows:1.Check thedetaileddescriptionof thefilesintherepositoryinSection84

  4. COMP424Artificial intelligence_第3张图片

    FinalprojectCOMP 424,McGillUniversitypythonsimulator.py\--player_1human_agent\--player_2random_agent\--displayYou can play with youragentlikewiseby using thename youregisteredyour agentwith(e.g.“studentagent”).ToquicklyplaythegamewithoutdisplayingtheUI,removethe--displayflag.3.5TestingandAutoplaySincethegame setupisnon-deterministic,yoursubmittedagentwillbeevaluatedon multiplerunsbyplayingthemagainsttherandomagentorotherstudentsubmissions.Thisisachievedbytheautoplaymode,enabledby--autoplayflaginsimulator.py.Thus,itiscrucialthatyou testyouragentagainsttherandomagentbeforesubmittingyourwork.You can playwith theflag--autoplayrunstosetthenumber of simulations.Inautoplaymode,thestartingagentisswappedeveryotherrun,soastoremovethedisadvantageofstartingfirstinthegame.During autoplay,ifyour agentdoes notadheretothe boundary conditionsof theboard,orattemptstomakeaninvalidmove (morethanKsteps),thegameenginewillautomaticallyrunarandom walkonbehalfofyouragent.Thismay adverselyafectyouragentsperformanceduring evaluation.You should testyour agentthoroughly for theseedge cases.3.6SubmissionFirst,fillyourandyourteam membersdetailsinauthors.yamlfileintherepository.Youshouldperiodicallycommityourcodeandpushittotherepositoryassignedtoyou.Yourcodewillbeautomaticallydeemed submittedpostthedeadlinedate.You cancontinuetomakechangesintheGithubClassroomrepositorybeforethedeadline.Any changespostthedeadlinewillnotbeusedforthefinalevaluation.4.ReportYouarerequiredtowriteareportwithadetailedexplanationofyourapproachandreasoning.ThereportmustbeatypedPDF file,andshouldbefreeofspellingand grammarerrors.The suggestedlengthisbetween 4and8pages,butthemostimportantconstraintisthatthereportbeclearandconcise.Youshouldusethesourceofthisdocument2asatemplatetowriteyourreportinLATEX.Thereportmustincludethefollowingrequiredcomponents:•An explanationof howyourprogram works,andamotivationforyourapproach.•A brief descriptionof thetheoreticalbasisof theapproach (abouta half-pageinmostcases);references to thetext of other documents,such as the textbook,are appropriate2.You can find the source of thisdocument in Overleaf here:https://www.overleaf.com/read/gcpfjdpqpytp.You would need tocreatean Overleaf account.Copy thisprojectand createa newprojecttowriteyourreport.Replacetheauthorinformationwithyourown groupinformation.5

  5. COMP424Artificial intelligence_第4张图片

    but notabsolutely necessary.If youuse algorithms from other sources,brieflydescribethealgorithmandbe suretociteyoursource.•A summary of theadvantagesanddisadvantagesofyourapproach,expectedfailuremodes,orweaknessesofyourprogram.•If youtriedother approachesduring the courseof theproject,summarize them brieflyanddiscusshow theycomparedtoyourfinalapproach.•A brief description (max.half page)of how you would go aboutimproving your player(e.g.by introducingotherAItechniques,changinginternalrepresentationetc.)4.1SubmissionTosubmityourreport,youshouldalsoaddthereportPDF directlyintherepositoryinthereportfolder,renameittoreport.pdf,andcommitandpushyourreportalongsidewithyourcode.5.Grading Scheme50% of theprojectgradewillbeallottedforperformanceinthetournament,andtheother50% willbe basedon yourreport.5.1TournamentGrading SchemeThe top scoringagentwillreceivefullmarks forthetournament.The remaining agentswillreceivemarks according to a linear interpolation scheme based on thenumber of wins/lossestheyachieve.To geta passinggradeon thetournamentportion,youragentmustbeattherandom player.5.1.1Tournament ConstraintsDuring thetournament,we willusethefollowingadditionalrules:•Execution Environment.We will run the tournamenton Linux environment(CentOS7),Python3.9andinstalllibrariesasdefinedinrequirements.txt.However,you arenotallowedtouseexternallibraries.Thismeans built-inlibrariesforcomputation areallowed butlibrariesmade specifically formachine learning or AI are not.Ifyou think you would require some external libraries not specified inrequirements.txtandwhich isnotaAI/ML specificlibrary,pleasepostaquestioninEd togetanapprovalfromtheTAs.•Turn Timeouts.During each game, your agent will be given no more than 30 secondsto choose itsFirstmove,and no more than 2 seconds to chooseeach subsequentmove.Theinitial30secondperiodshouldbeusedtoperformanysetuprequiredbyyouragent(e.g.loadingdata fromfiles).Ifyourplayerdoesnotchoosea movewithintheallottedtime,arandom move willbechoseninstead.Ifyouragentexceedsthetimelimitdrastically(forexample,ifitgetsstuckinaninfiniteloop)thenyou willsuferan automaticgame loss.6

  6. COMP424Artificial intelligence_第5张图片

    FinalprojectCOMP 424,McGillUniversity•Illegalmoves.Inthegame,ifyouragentattemptstomovetopositionswhichareillegal,i.e.whichrequiresmorenumberofstepsthanK,thenwewillrunarandomwalk overthegame board.If yourcode failsduring execution,then the game will alsocontinuewitha random move.•Multi-threading.Your agent will be allowedto usemultiple threads.However,youragentwillbeconfinedtoasingleprocessor,sothethreadswillnotruninparallel.Also,you arerequiredtohaltyourthreadsattheend of yourturn(soyou cannotbecomputingwhileyouropponentischoosingtheirmove).•FileIO.Your playerwillnotbeallowedtoreadand writefiles:allfileIO isprohibited.Inparticular,youarenotallowedtowritefiles,soyouragentwillnotbeabletodoany learningfromgame togame.•Memory Usage.Youragentwillruninitsown processandwillnotbeallowedtoexceed500mb of RAM.ExceedingtheRAM limitswillresultinagame loss.Youarefreetoimplementanymethodofchoosingmovesaslongasyourprogramrunswithintheseconstraintsandiswelldocumentedinboththewrite-upandthecode.Documentation is an important partof softwaredevelopment,so weexpectwell-commentedcode.Allimplementationmustbe yourown.5.2ReportGradingSchemeThe marksforthewrite-upwillbeawardedasfollows:•TechnicalApproach:20/50•MotivationforTechnicalApproach:10/50•Pros/consofChosenApproach:5/50•FutureImprovements:5/50•Languageand Writing:5/50•Organization:5/506.Academic IntegrityThisisagroupproject.Theexchangeofideasregardingthegameisencouraged,butsharingof codeandreportsisforbiddenandwillbetreatedascheating.We willbeusingdocumentand codecomparison toolstoverifythatthesubmittedmaterialsarethework ofthe authors only.Please see thesyllabusand www.mcgill.ca/integrity for more information.7.ContactFeelfreetocontacttheTA’sifyou haveany specificconcernthatneedstobeaddressed.•KoustuvSinha,[email protected]•ShuhaoZheng,[email protected]

  7. COMP424Artificial intelligence_第6张图片

    8.Detaileddescriptionof therepositoryThestartercodecanbeviewablehere:https://github.com/Ctree35/Project-COMP424-2022-Winter.The followingdescribestheusageofeachcomponentof thiscode:|-store.py#Storingagentsfordecorator|-world.py#MainGameenginecode|-requirements.txt#Specifyexternallibrariestobeinstalledusedpip|-test#Unittestfiles||-conftest.py||-test_agent.py#TestcaseforAIagents||-test_world.py#Testcaseforgameengine|-ui.py#UIEnginefiles|-authors.yaml#Studentsshouldfilloutauthorinformation|-constants.py#Handyconstantsforthegame|-agents#Directorycontainingallagents||-random_agent.py#Agentthattakesrandomwalk||-__init__.py#Allagentsshouldbeimportedhere||-human_agent.py#Humanagentusingwhichyoucanplayinteractively||-agent.py#Baseagentclass||-student_agent.py#ImplementyourAIhere|-README.md|-utils.py#Someutilitiesforthegame|-simulator.py#Mainentrypointforrunningthegame|-report#Uploadyourreportinthisdirectory||-README.md8

你可能感兴趣的:(人工智能)