Also includes notes for each step.
ELET2300 Assignment4 SubmityourprogramthroughBlackboard–Nolatesubmissions! Makesurethatyouuploadtherightfile(usually:main.cpp)!!! Inthisassignment,youwillimplementasimplifiedgameofDarainC++fortwo(human)players. 1.Firstbesuretounderstandhowthegameworks.Asummaryofthegamerulescanbefoundat theendofthisdocument.YoucanalsofindextrainformationatWikipedia: https://en.wikipedia.org/wiki/Dara_(game)andYouTube(https://youtu.be/4pEY9MUYibU). 2.Theoriginalgamestartswiththeplayerstakingturnstoplace12pieceseachona5x6square board(i.e.,the"drop"phase).Tosimplifytheverificationofyourprogram,theprogramwill readtheinitialboardsetupfromafileinsteadofaskingtheplayerstoenterthelocationsofthe initialpieces.Anexampleofthefilecontentsis: .XOXOX .XOOXX O.XOOX O.XO.O XOX.XO where"X","O"representthetokensofplayer1and2respectively.Thedot(.)representsan emptycell. Inyourprogramtheboardwillberepresentedasachararray.Donotusestrings.Implementthe filereadingandboardinitializationinaC++functionnamed"readBoard". 3.Yourprogrammustverifywhetherthisinitialconfigurationisavalidone,i.e.,makesurethat eachplayerhasexactly12piecesontheboardwithoutany3-pieceormorehorizontal/vertical row(seethegamerules). 4.Implementthefunction"displayBoard",whichasthenameimplies,willshowthecurrentstate ofthegameonthescreen. 5.WriteaC++loopinmain()toimplementthe"movephase"ofthegame.Theloopwill: A. Askplayer1forthelocationofthepiecethatshewantstomoveandthemovement direction('u','d','r','l'forup,downright,left).Ifthepieceattherequestedlocation belongstotheplayerANDthetargetcellisfree,thenexecutethemove.Otherwise,print anerrorandasktheusertoenteradifferentlocation/movedirection. B. Intheoriginalgame,avalidmovecannotformacolumn/rowof4equalpiecesormore andcannotputthelatestpiecebacktoitspreviouslocation.Thesetworulesareoptional forthisassignment,butyoucanimplementthemextracredit. C. Afteravalidmove,checkwhethera3-samepiecehorizonalorverticalrowwasformed. Ifso,asktheuserforthelocation,i.e.,therownumber,columnnumber,ofthepieceshe wantstocapture.Verifythatthelocationcontainsanopponent'spieceandthatisnot empty.Ifso,removethatpiece(makethatcellempty).Ifnot,askagaintheuserfora validlocation. D. Aftereachcapture,checkwhetherthegamehasended(i.e.,opponenthasnomore piecesontheboard).Ifso,printamessageannouncingso. E. Oncethegamehasended,askwhethertheywanttoplayagain.Ifso,restartthegameby re-readingtheinitialboardfromthefile(step2above).Ifnot,terminatetheprogram. DesignthemainloopinmodularformusingadditionalC++functions.Forexample,youcan implementa"gameover"functionthatcheckswhetherallopponent'spieceshasbeencaptured andthenmakecalltothatfunctionfrommain(). Notes: • YoumustuseonlytheC++instructionsthatwehavecoveredsofarinclass. • Theprogramthatyouturninmustbeyouroriginalandindividualwork.Whileyouareallowedto discusstheprogramassignmentsingeneraltermswithothers,youarenotallowedtosharedetailsof theactualsolution(s)orprogramcodewithanybodyexcepttheinstructor. • Turninginacopyofsomeoneelse'sprogram,evenacopywithextensivechangesmadetoit,or receivinganyunauthorizedassistanceisaveryseriousoffenseinthiscourse. • Anautomatedplagiarismcheckermayscanprogramsatanytimeduringthesemester. • Onlysubmityoursourcecode(.cpp).ThismustbedoneonorbeforetheduedatethroughBlackboard. Nolatesubmissions.Blackboardwillautomaticallyclosethesubmissionpagerightafterthedeadline. • Yourprogrammustincludecommentsexplainingyourstepsandmustbeproperlyformatted(see Program_Style_Guidelines.pdfinBlackboard). /∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗ELET2300
∗ProgrammingAssignment
∗ *Compilertype(ifotherthenVisualC++) ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/ *CourtesyoftheMindResearchInstitute