/
SEARCHINGWITHANALYSISOFDEPENDENCIESINASOLITAIRECARDGAMEB.Helmstetter,T SEARCHINGWITHANALYSISOFDEPENDENCIESINASOLITAIRECARDGAMEB.Helmstetter,T

SEARCHINGWITHANALYSISOFDEPENDENCIESINASOLITAIRECARDGAMEB.Helmstetter,T - PDF document

lindy-dunigan
lindy-dunigan . @lindy-dunigan
Follow
361 views
Uploaded On 2015-10-27

SEARCHINGWITHANALYSISOFDEPENDENCIESINASOLITAIRECARDGAMEB.Helmstetter,T - PPT Presentation

344BHelmstetterTCazenaveThispaperisorganisedasfollowsWeexplaintherulesofGapsinSection2WegiveresultsofthebasictechniquesandexplainthereasonsforourapproachinSection3WepresentourmethodinSection4and ID: 173979

344B.Helmstetter T.CazenaveThispaperisorganisedasfollows.WeexplaintherulesofGapsinSection2.WegiveresultsofthebasictechniquesandexplainthereasonsforourapproachinSection3.WepresentourmethodinSection4and

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "SEARCHINGWITHANALYSISOFDEPENDENCIESINASO..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

SEARCHINGWITHANALYSISOFDEPENDENCIESINASOLITAIRECARDGAMEB.Helmstetter,T.CazenaveUniversiteParis8,laboratoired'IntelligenceArti cielle2,ruedelaLiberte93526Saint-DenisCedexFrance{bh,cazenave}@ai.univ-paris8.frAbstractWepresentanewmethodfortakingadvantageoftherelativeindependencebetweenpartsofasingle-playergame.Wedescribeanimplementationforim-provingthesearchinasolitairecardgamecalledGaps.Consideringthebasictechniques,weshowthatasimplevariantofGapscanbesolvedbyastraight-forwarddepth- rstsearch(DFS);turningtovariantswithalargersearchspace,wegiveanapproximationofthewinningchancesusingiterativesampling.Ournewmethodwasdesignedtomakeacompletesearch;itimprovesonDFSbygroupingseveralpositionsinablock,andsearchingonlyontheboundariesoftheblocks.Ablockisde nedasaproductofindependentsequences.Wedescribepreciselyhowtodetectinteractionsbetweensequencesandhowtodealwiththem.TheresultingalgorithmmayruntentimesfasterthanDFS,dependingonthedegreeofindependencebetweenthesubgames.Keywords:depth- rstsearch,dependency-basedsearch,blocksearch,Gaps1.IntroductionInthispaperweconsiderasolitairecardgameusuallycalledGaps,Montana,RangoonorBlueMoon.WegiveapproximationsofwinningchancesforthegameofGapsandusethedomainfortestingnewideas.Inthe®eldofsolitairecardgames,wemayalsomentionthegameFreecellwhichhasbecomeatestdomaininplanning(Hoffmann,2001).WehavereasonstobelievethattechniquesbasedonheuristicsarenotveryusefulinGaps.Howeverwehavebeenabletoimprovethesearchinanotherway,byprovingtheindependencebetweenmovesindifferentpartsofthegameandmakinguseofit.Afewsearchtechniqueswithsimilarconcernsexistbuttheyarebasedondifferentprinciples(Allis,1994;JunghannsandSchaeffer,2001;Botea,Muller,andSchaeffer,2002).. 344B.Helmstetter,T.CazenaveThispaperisorganisedasfollows.WeexplaintherulesofGapsinSection2.WegiveresultsofthebasictechniquesandexplainthereasonsforourapproachinSection3.WepresentourmethodinSection4andexperimentalresultsinSection5.Finally,inSection6wediscusspossibilitiesforgeneralizationandcompareourmethodtotheexistingonewhichistheclosest:dependency-basedsearch(Allis,1994).Afterourexperiments,itwasasurpriseto®ndthatagamecalledSuperpuzz,studiedbyBerlinerandmorerecentlybyShintani,isavariantofGaps.How-ever,atthetimethispaperwaswritten,wedidnotknowpreciselywhatworkhasbeendoneonSuperpuzz.WehavefoundashortdescriptionofBerliner's(1997)workontheweb,andShintani's(1999,2000)workhasonlybeenpublishedinJapanese.RulesoftheGameBelowweexplaintherulesofwhatwecallthebasicvariant(2.1).Thenwedescribeafewothervariants(2.2).Finally,wegivesomebasicpropertiesofthegame(2.3).2.1BasicVariantThegameisusuallyplayedwitha52-carddeck.Thecardsareplacedin4rowsof13cardseach.The4Acesareremoved,resultingin4gapsintheposition;thentheyareplacedinanewcolumnattheleftina®xedorder(e.g.,1strowSpade,2ndHeart,3rdDiamond,4thClub).Thegoalistocreateorderedsequencesofthesamesuit,fromAcetoKing,ineachrow.Amoveconsistsinmovingacardtoagap,thusmovingthegaptowherethatcardwas.Agapcanbe®lledonlywiththesuccessorofthecardontheleft(thatis,thecardofthesamecolourandonehigherinvalue),providedthatthereisnogapontheleftandthatthecardontheleftisnotaKing,inwhichcasewecanplacenocardinthatgap.Figure1showsaninitialpositionwithonly4cardspersuit,beforeandaftermovingtheAces,andthepossiblemoves.4}4|4~3|242~2|33}3~11}1|4}23}3|434|2~3~2|4~11~1}1|1~2}2}Figure1.Aninitialpositionwith4x4cards,beforeandaftermovingtheAces.Thispositioncanbewon. SearchingwithAnalysisofDependenciesinaSolitaireCardGame3452.2OtherVariantsThebasicvariantpresentedaboveisprobablynotthemostcommon.UsuallytheAcesarenotplacedinanewcolumnbutarede®nitivelyremoved.InsteaditisallowedtoplaceanyTwoinagapifitisonthe®rstcolumn.ThisgivesmorepossibilitiesthaninthebasicvariantwhereonlyoneTwocangoineachplaceofthesecondcolumn(whichwasthe®rstbeforemovingtheAces).Thisdifferenceisnotaminorone,asithasastronginuencebothonthesizeofthesearchspaceandontheprobabilityofawinninggame,aswewillsee.Wecallthisvariantthecommonone.Thereasonforourchoiceofthebasicvariantwastomaketherulescleaner;thiswayonlyonecardcanbeplacedinanygap.Thegameisusuallyplayedwithanadditionalrulewhichsaysthatwhentheplayergetsstuck,hemayremovethecardsthatarenotpartofanincreasingsequencestartingfromthe®rstcolumn,andredealthem.Tworedealsareallowed.Wehavenotstudiedthegamewiththisrule.However,aswewillsee,theprobabilityofwinningwithoutthisrulebutwithperfectplayishigherthanthatobtainedbyhumanplayersusingthisrule.Itispossibletochangethenumberofsuitsandthenumberofcardspersuit.Thisinuencesthesizeofthesearchspaceandtheproblem'sdif®culty.Italsohasaneffectonthedegreeofindependencebetweensubgames,whichwillbeamajorconcern.ThegamethathasbeenstudiedunderthenameSuperpuzziswhatwehavecalledthecommonvariant.Thereisonlyoneminordifference:thegapsarecreatedbyremovingtheKingsinsteadoftheAces.2.3PropertiesInthebasicvariant,everyinitialdealingresultsinaseparategameofperfectinformation.Thisversionhasaremarkableproperty:inanyposition,thedepthofthesearchgraphisbounded;inparticularthereisnocycle.Ifwelookataparticularcard,ofvaluev,thereisonlyv1placeswhereitcouldbeinthesubsequentpositions,inadditiontoitspresentlocation:itcouldbeonespaceontherightofthecardofthesamesuitandofvaluev1,twospacesontherightofthecardofthesamesuitandofvaluev2(whichmeansthatwehavebuiltasequencev2;v1;vfromthecurrentpositionofthecardofvaluev2andofthesamesuit):::,andv1spacesontherightoftheAceofthesamesuit.Thecardcannotgotoanyofthoseplacestwice,sothenumberofmovesofthiscardisboundedbyv1.Thereforethetotalnumberofmoveswith52cardsisboundedby4(1+2+3+:::+12)=312. 346B.Helmstetter,T.Cazenave3.BasicTechniquesInthissectionweshowresultsofeitheradepth-®rstsearchoraniterativesamplingsearchappliedtoGaps,thenwediscusspossibilitiesforimprovement.Althoughthetechniquesexposedherearebasic,theresultsareaboutthebestwecoulddowithoutusingthemethod,blocksearch,thatwepresentinthenextsection.Depth-FirstSearchItturnsoutthatinthebasicvariantthesearchspaceissmallenoughtoallowacompletedepth-®rstsearchenhancedwithatranspositiontable.Assumingthatwestopthesearchassoonaswe®ndawinningpath,theaveragesizeofthesearchspaceisabout250,000.Itseldomgoesabove2million.Thisissmallenoughforallpositionstobestoredinatranspositiontable.Ateston10,000initialpositionsshowsthattheprobabilitythataninitialpositioncanbewonisabout24.8%.Thelengthofwinningsolutionsisusuallyintherangeof90to130moves.AllthecomputationshavebeenmadeonanAthlon1600+with1GBRAM.Theprevioussearchtakesabout0.2sperproblem.Thisisonlythebeginningofthestorythough,becausethebasicvariantisfarfrombeingthemostdif®cultone,andeveninthebasicvariantthedif®cultycouldbeincreasedbyplayingwithmorecards.3.2IterativeSamplingDFSisimpracticalinvariantswherethesizeofthesearchspaceistoobig.Instead,iterativesampling(HarveyandGinsberg,1995)hasprovedtobesurprisinglyef®cient.Thisconsistsinplayingcompletelyrandommovesuntilagoalisfoundortheplayergetsstuck,inwhichcasethesearchrestartsatthebeginning.Thisisrepeateduntilaprobeissuccessfulorthemaximalnumberofprobesisreached.Wegiveresultsofthisalgorithmbothforthebasicvariantandforthecommonone(wheretheAcesarede®nitelyremovedandanyTwocangointhe®rstcolumn).Weconsiderthecommonvariantbecausethetypicalsizeofitssearchspaceistoobigtoallowacompletesearchinareasonabletime(thispropertycouldalsohavebeenobtainedbyincreasingthenumberofcards).Thiswaywealsogeta®rstapproximationofthewinningchancesforthecommonvariant,whichareunexpectedlyhigh.Table1showstheresultsofanexperimentonasetof1000randominitialpositions.Thesetofpositionsisalwaysthesame,exceptthat,foraccuracy,experimentswithfewerthan1000probeshavebeenmadeon100,000initialpositions.Oneprobetakesabout4.5s.Thisamountstoabout450sfor108 SearchingwithAnalysisofDependenciesinaSolitaireCardGame347probeswhentheyareunsuccessful;onaverage425sand164sforthebasicandcommonvariants,respectively.maxnumbersuccessratesuccessrateofprobesbasicvariantcommonvariant10.046%0.041%100.373%0.396%1021.37%2.96%1047.1%26.6%1059.7%43.1%10612.8%53.0%10714.5%60.3%10816.4%66.9%Table1.Resultsofiterativesampling.Itisaparticularityofourdomainthatwehaveaslightchanceofwinningbydoingran-dommoves.Theef®ciencyofthealgorithmisduetoitscov-eringawell-distributedpartofthesearchspaceanditsavoid-inggettinglostinlargepartsofthetreewhereitisimpossibletowin.3.3CombiningaDepth-boundedSearchwithIterativeSamplingIterativesamplingcanbecombinedwithadepth-boundedcompletesearch.Onepossibilityistomakeabreadth-®rstsearchuntilexhaustionofmemoryresources,andtomakeoneormorerandomprobesateachnodeofthissearch.Theresultsarebettercomparedtosimpleiterativesampling,probablybecauseitensuresabetterdistributionoftheprobesinthesearchspace.Furthermorethismethodwillalsoprovesomeproblemsimpossiblewhenthesearchspaceissearchedcompletely.Wehaverunateston100randominitialpositionsforthecommonvariant.Thebreadth-®rstsearchwaslimitedbythenumberofpositionsthatcouldbestoredinmemory:thisnumberwassetto5;000;000.Onerandomsamplewasperformedateachnode.Theprogramtook144sperprobleminaverage,andithasfoundsolutionsfor88oftheinitialpositionsandproved4impossible.3.4ComparisonwithHumanPerformanceEstimationsofthechancesofwinningforhumanplayersarebasedonvarioussourcesfromthewebandonpersonalexperience.Thechancesofwinningwhennoredealisallowedareofabout1%.Theexactruleconcerningthegapsinthe®rstcolumnapparentlyhaslittleeffectonthedif®cultyofthegameforhumanplayers,butwehaveshownitisimportantforthecomputer.Thelastfeaturemustbecomparedwith24.8%(basicvariant,completeDFS),66.9%(commonvariant,iterativesampling)and88%(commonvariant,combinationofbreadth-®rstsearchanditerativesampling).Withtworedealsallowed,chancesofwinningforhumanplayersareofabout25%,stillwellbelow88%. 348B.Helmstetter,T.Cazenave3.5DiscussiononPossibilitiesforImprovementIterativesamplingisasimpleandef®cienttechniqueforthegameofGaps;however,intheprocessofdesigningasearchprogramforsolvingGaps,thistookusquitesometimetorealize.Previously,ourattemptsforsolvingGapsanditsvariantswerebasedoncomplexbest-®rstsearchalgorithms.Wegraduallyrealizedthatitwasimportanttotryandgotothegoaloftenwithoutcaringmuchforthequalityofthemoves.Atthattimeouralgorithmswereaboutasfollows:dosometreesearchinabest-®rstway,andduringthissearch,fromtimetotime,launchrandomsamplings.We®nallyfoundthatthestrengthofourprogramwasalmostentirelyduetotherandomsamplings.Atthebeginning,wehadbeenworkingonyetanothervariantofthegame.Thisvariantdiffersfromthecommononebytherulethatwemaymoveinagapnotonlythesuccessorofthecardontheleftbutalsothepredecessorofthecardontheright.Wefeltthatthereweremuchmoreef®cientheuristicsinthisvariant.Wedidgetsomesuccessesusingheuristics,buteventhererandomsamplingalonewoulddoaboutaswell.Inthebasicvariantthesituationisworse.Whatheuristicsdowehave?First,thereisthenumberofcardsthatarealreadyintheir®nallocation.Thisistheonlysimpleheuristicweknowabout,butunfortunatelyitgivesapoorevaluationoftheposition,asitoftenhappensthatmostcardsonlygetintheircorrectlocationintheendgame.Thentherecouldbeheuristicsconcerningthemobilityofthecards,inthepresentandinthelongterm,butthisisdif®culttoestimate.Itispossiblethatgoodheuristicscouldbefound.Howeveracomparisonwithhumanperformanceshowsthatwearenotsobadwithiterativesampling.Onecanseethatonesamplebyhumanplayersisroughlyassuccessfulas100randomsamples.Thisindicatesthathumanplayersdonotuseveryef®cientheuristicsanyway.Evenifwecoulddoaswellashumansononesample,consideringthetimethatwouldbeneededforcomputingheuristicsitwouldprobablynotbeinteresting.Becauseheuristicsareweak,anybest-®rstsearchalgorithmwouldalsobeoflimiteduse.Asanexamplethereisthewell-knownIDA*;wehaveexperimentedwithitbutdidnotachievebetterresultsthanwithadepth-®rstsearch.Thenextpartofthispapertakesanorthogonalapproachtotheheuristicone.Ourgoalistogothroughthesearchspacecompletely,withoutevencaringwhetherwe®ndawinningsequence.Wewanttodoitfasterthanadepth-®rstsearchwould,bysimplifyingthesearchspace.Thankstothis,wewillbeabletodetermineforsureifthereisasolutioninsomeproblemswheredepth-®rstsearchisnotapplicable;forinstanceinthebasicvariantwhenplayingwithmorecards. SearchingwithAnalysisofDependenciesinaSolitaireCardGame3494.BlockSearchInthissectionwepresentanewmethodthataimsatprovingtheindependencebetweensomepartsoftheproblemandtakingadvantageofit,whilekeepingthesearchcomplete.Fromnowonthefocuswillbeonthebasicvariantonly,becausewewillmakeuseofthefactthatinanypositiononlyonecardcanbeplacedinagap.Thecommonvariantdoesnothavethisproperty,andthereforemoreworkwouldbeneededinordertogeneralizethemethodtothisvariant.4.1RelatedWorkAmongexistingsearchalgorithms,theclosesttooursisprobablythealgo-rithmdependency-basedsearchbyVictorAllis(1994).Heappliedhismethodtothreedomains:thedoubleletterproblem,andthesearchofwinningse-quencesinQubicandGoMoku(thelasttwo,being2-persongames,were®rsttransformedintosingleagentgames).InfactthestartingpointofourworkwasafailuretoadaptthisalgorithmtothegameofGaps.Apseudo-codeforthealgorithmwasgiven,butafunctioncalledNotInConictwasnotexplicit;webelievethatthisfunctionwaseasytowriteinthedomainswherethealgo-rithmhadbeenimplementedbutwouldbedif®culttowriteinGaps,atleastnotstatically.ThegoalofourmethodisalsosimilartothatofJunghanns'RelevanceCutsforSokoban(JunghannsandSchaeffer,2001).Hesuggestedthatrelevancecanbeapproximatedbycomputinganinuencebetweenmoves,andthenpenaliz-ingmovesthatarenotrelevanttothepreviousones.HisworkwasdoneinthecontextofanIDA*search,soinhismethodmovesareneverde®nitelyelimi-nated,theymayonlygetapenalty.Themethodwehavedevelopedhandlestheproblemmoreprecisely.AmorerecentworkonSokoban(Botea,Muller,andSchaeffer,2002)ad-dressestheprobleminyetanotherway,bydecomposingthepositioninroomsandprecomputingthegraphofstatesineachroom.Themajordifferencewithourworkisthatthestatesinthesubgamesareprecomputed,andthisdoesnotseempossibleinGaps.4.2PrincipleoftheMethodWenamethefourgapsA,B,C,D,andbreakthegameintofoursubgamesalsonamedA,B,C,D.Themovesallowedinonesubgamearethosethatusethecorrespondinggap.Ifoneplaysonlyinonesubgame,onemakesalinearsequenceofmoves.Thissequencemovesthesamegapfromplacetoplaceuntilgettingstuck,whichcanhappenforanyofthefollowingtworeasons:eitherthereisanothergapontheleft,orthecardontheleftisaKing.Whereasthe 350B.Helmstetter,T.Cazenavemovesinthesamesubgamearetotallyordered,movesfromdifferentsubgamesareoftenindependent.Wewanttotakeadvantageofthisrelativeindependencebetweenthesubgames.Letablockbede®nedbyitsstartingposition,andineachsubgameXasequenceSX,possiblyempty,fromthestartingposition,sothatthefoursequencesareindependentofeachother.Ablockrepresentsasetofpositions:allpositionsthatcanbereachedfromthestartingpositionoftheblockwiththemovesofthesequencesSXinanyorder.Ithelpstoseeablockgeometricallyasembeddedinafourdimensionalspace.IflXisthelengthofsequenceSX,theblockrepresentslAlBlClDpositions.Finally,wecallFXthefaceoftheblockthatconsistsinthepositionsoftheblockwhereallthemovesofsequencesSXhavebeenmade.Themainideaofthealgorithmis:insteadofsearchingonepositionatatime,wesearchoneblockatatime.Insteadofrecursivelysearchingtheimmediatechildrenofaposition,weconstructnewblocksattheboundaryofablockandrecursivelysearchthem.Wewanttoconstructblocksofthebiggestpossiblesize,sobeforebuildingblocksontheboundary,wetrytoextendthemasmuchaspossibleinthefoursubgames.Figure2showsapseudo-codeforthealgorithm.voidsearch(block)fforeachsubgameXextendblockinthesubgameX,aslongasallthesequenceskeepbeingindependent;foreachsubgameXbuildnewblocksnearthefaceFXoftheblock,suchthatanymovewecandofromFXgoestooneofthoseblocks,andsearchthemrecursively;testforawinningpositionintheblock;gFigure2.Pseudo-codeforblocksearch.Westillhavetoshowhowtoextendblocksandconstructnewblocksattheboundaries.Besides,thepseudo-codedoesnotincludeatranspositiontable,andthiswillleadtosomeproblemstobeaddressedinSubsection4.7.4.3StudyoftheBasicInteractionWestudyindetailthecaseofasingleinteractionbetweentwosequences.Figure3showstheusefulpartofthepositionandadiagramwhichsynthesizestherelationbetweenthetwosequences.Forsimplicityallcardsareofthesamesuit.Weassumethatbothsequencesbeginafewmovesbeforetheinteractionandendafewmovesafter,althoughthemovesthatarenotcriticalhavenotbeen SearchingwithAnalysisofDependenciesinaSolitaireCardGame351drawn.ThedottedarrowintherightdiagramindicatestheactionofsequenceSBonsequenceSA.Assumewearejustaftermovea1inSA.Ifb1hasnotyetbeenmade,movea2canbemadeinsubgameA;ifmoveb2hasalreadybeenmade,movea0canbemadeinsubgameA;ifmoveb1hasbeenmadebutnotmoveb2,nomovecanbemadeinsubgameA.35784b1b2a1a2a2'2b1a1a2'Gap ASubgame BSubgame Aflow of96Figure3.Abasicinteraction.startingb1b2psubgame Asubgame Ba1a2'a2Figure4.Searchspacecorrespondingtoabasicinteraction.Figure4showsarepresentationintheplaneofthesearchspace,wherethepositionslieattheintersectionsofthelines.Imaginetherewasnointeractionbetweenthetwosequences;wewouldhaveabigsquarewiththeentirese-quencesAandBontheedges.Theeffectoftheinteractionistocutthissquarealongalinefromthepointptotherightside(thedoublelineinthe®g-ure),andtostickanotherpartalongthecut,whichcorrespondstosequenceSAtakingthebifurcation.Thepositionatpisparticular:itisthepositionwherethetwogapsareadjacent,sothatnomovecanbemadeinsubgameA.ThispointcorrespondstothedottedarrowinFigure3.WesaythatthereisabifurcationofsequenceSA,causedbyanactionofsequenceSB.OnemustimaginethattherearetwootherdimensionscorrespondingtothesubgamesCandD;ifthesequencesinthesesubgamesdonotintroducenewinteractions,thecompletesearchspacewillbeasimpleproductofthegraphinFigure3withthesequencesSCandSD.Wearelookingforwaystopartitionthesearchspaceintoblocks.Thereareseveralwaystodoit;Figure5showsthetwowayswewilluse.Theydealwiththetwopossibleshapesofthe®rstblock.Whetherwegetinthe®rstorintheseconddependsontheorderinwhichwehaveextendedthe®rstblock:®rstinsubgameAorB.Subsection4.6willexplainpreciselyhowtodetectinteractionswhenextendingblocksandhowtobuildnewblocksattheboundary.Forthemoment,wenotethatinthe®rstpossibilityblocks2and3 352B.Helmstetter,T.Cazenavearechildrenofblock1,whereasinthesecondonlyblocks2and4arechildrenofblock1,andblock3isachildofblock2.123pa1a2a2'b1b2subgame Bsubgame A1234subgame Bpa2a2'b2b1subgame AFigure5.Twowaystodecomposethesearchspaceintoblocks.4.4WhytheBasicInteractionistheOnlyOnetoConsiderWehaveshownhowtodealwiththebasicinteraction;itturnsoutthatitistheonlyonewehavetoconsider.LetSXandSYbetwosequencesinthesubgamesXandY.LetusenumerateallthewaysthatamoveyofsequenceSYcouldbeinuencingamovexofsequenceSX.Movexconsistsintakingthecardcfromplacep1toplacep2.Theprerequisitesforthismoveare:1thereisagapatp2,2thecardcisinp1,3thecardattheleftofp2,cL,isthepredecessorofc.Thosepreconditionsareveri®edifwemakeonlymovesfromsequenceSXuptox,buttheycouldbedestroyedbymovesofsequenceSY.AssumewehavealreadyestablishedtheindependenceofthesequencesSXandSYuptothemovesxandy;thenprecondition1isautomaticallysatis®edassoonaswehaveexecutedallthemovesofsequenceSXuptoxandwhateverwehavedoneinthesequenceSYuptoy,sinceitisaneffectofthebeginningofsequenceSXtoputagapinp1.Precondition2isautomaticallysatis®edtoo.ThiscomesfromthefactthatthecardccanonlygototherightofcL,whereverthiscardbe.IfthiscardwasmovedbysequenceSY,thentherewouldalreadybeaninteractionbecauseofprecondition3.IfmoveymovedcardctotherightofcLandthiscardwasstillattheleftofp2,thetrajectoriesofthegapsXandYinthesequencesSXandSYuptoxandywouldbothpassthroughp2,whichagainwouldimplythattheyaredependent.Thereforeonlyprecondition3remainstoconsider,whichproducesaninter-actionofthekindalreadyanalysed. SearchingwithAnalysisofDependenciesinaSolitaireCardGame3534.5UsingaTracetoSpeedUptheDiscoveryoftheInteractionsThetraceofthesequencesSXisanarrayofthesamesizeastheposition(4x13).Itcontainsinformationforeachplacepindicatingwhetherandatwhichmovethetrajectoryofthegapforanysequenceispassingthroughp.Thetraceismaintainedincrementallyaswebuildnewblocks.Assumewemakeanewmovem,whichmovesacardfromp1top2.Wewanttoknowifitproducesnewinteractionswiththesequencesalreadybuilt.Alookinthetraceattheplacejustontheleftofp2showsifanysequencehasaneffectonmovem.Alookinthetraceattheplacejustontherightofp1showsifmovemhasaneffectonanysequence.Thiswaythesearchforaninteractionisdoneveryquickly.Themethodofdoingalocalsearchandstoringthesetofpropertiesofthepositiononwhichtheresultrelieshasalreadybeenusedbyotherpeopleindifferentdomains:inGo,withthegoalofincrementallyupdatinglocalresults(Bouzy,1997);inGeneralizedThreatsSearch(Cazenave,2002)whichisa2-playersselectivesearchalgorithmthatreliesonatraceto®ndasetofrelevantmoves;inthealgorithmH-searchusedinthehexprogramHexy(Anshelevich,2002)withabottom-upapproach,buildingincreasinglycomplexvirtualconnections.4.6BuildingandExtendingBlocksTheprocedureforbuildingblocksattheboundaryistricky,becausewehavetotakeintoaccountalltheinteractionsthatmightoccur.Althoughthereisonlyonekindofinteractionthatneedstobeconsidered,itcancomeinthetwodifferentcon®gurationsshowninFigure5,andwemustbepreparedthatseveralcon®gurationsoccuratatime.Figure6representsasearchspaceintwodimensionsthatgivesanideaofthekindofsituationswehavetodealwith.WeareonfaceFBofblockb.Wetryto®ndoutwhatmovescanbemadeinsubgameBdependingontheexactlocationonFB,andifthemoveshaveanactionontheothersequences.Thissituationoccurstwiceintheprogram:®rstwhenwearetryingtoextendtheblockinsubgameB(whichcanbedoneaslongasthereisnointeraction),secondwhenwearebuildingnewblocksnearfaceFB(generallybecausewehavealreadyfoundaninteraction).Wemustanswerthefollowingquestionsinthisorder.1IsthereanactionofanyothersequenceoftheblockthatwillcauseabifurcationonSB?ThisisthecaseifandonlyifthetrajectoryofthegapforanyothersequenceispassingthroughtheplaceattheleftofgapB.Thiscanbedecidedquicklybylookingatthetrace.Anexampleisinteraction1inFigure6. 354B.Helmstetter,T.Cazenaveno move possibleinteraction 1subgame Asubgame Bblock binteraction 2FBFigure6.Severalinteractionsononefaceofablock.2NowweknowthatthemovetobemadeinsubgameBdoesnotdependonthelocationonfaceFB,orwehavealreadyrestrictedourselvestoanareawhereitisthecase.Isamovepossibleatall?TherecannotbeanothergapontheleftofgapBbecauseofthepreviousstep,sothequestioniswhetherthecardontheleftisaKing(inthiscasetheblockcannotbeextended,andnoblockwillbeconstructedonthispartoftheboundary).3Nowweknowwecandoamove;thismovetakesacardfromaplacepandmovesitingapB.Isthereanactionofthismoveontheothersequences?Thisisthecaseifandonlyifthetrajectoryofthegapforanyothersequenceispassingthroughtheplaceattherightofp.Thistoocanbedecidedquicklybylookingatthetrace.Anexampleisinteraction2inFigure6.Whenbuildingnewblocksattheboundary,onemustgothroughthesethreesteps.Insteps1and3wemayhavetobreakfaceFBintotwoparts(insomedegeneratedcasestheremaybeoneorzeropart)andapplythefollowingstepstoeach.Afterstep3wehaveisolatedapartGofthefaceFX.WeknowthatwecanmakeamovemanywhereonGandthatthismovehasnoeffectontheothersequences.WethencreateanewblockbydoingmovemfromG,andsearchitrecursively.AblockcthathasjustbeenbuiltonfaceFXofablockbhasnodepthinsubgameX.Whenwetrytoextendblockcinallthesubgames,itisgenerallysuccessfulforsubgameSX;onthecontrary,itisgenerallynotsuccessfulintheothersubgamesbecausethereasonswhyblockbhadbeenstoppedinthosesubgamesoftenstandforblockc. SearchingwithAnalysisofDependenciesinaSolitaireCardGame3554.7AddingaTranspositionTableThedecompositioninblocksalreadyhandlesallthetranspositionswithintheblocks;thisisgoodbutinsuf®cient.Inorderforthealgorithmtobeef®cient,itisalmostcompulsorytohaveaglobaltranspositiontable.However,whenweconstructanewblockorwhenweextendone,therecouldbecommonpositionsanywhereinthisblockandinanotheralreadybuiltone.Nowwedonotwanttogotoallthepositionsineveryblockandmarktheminthetranspositiontable,becausetheadvantagesofourmethodwoulddisappear.Wehavetolookforacompromise:wecouldmarkonlyawell-chosenpartofeachblockandhopeitwillbesuf®cienttodetectmosttranspositions.Wede®nethenumberofpositionsofablocksearchasthesum,foreachblock,ofthenumberofpositionscontainedinthisblock.LetRbetheratiobetweenthenumberofpositionsofablocksearchandthenumberofpositionsofadepth-®rstsearch.Ideally,ifthetranspositionstableislargeenoughtocontainallthepositionsofthesearchspaceandiftheblocksaremutuallydisjoint,thenR=1.Iftheblocksarenotmutuallydisjoint,thenRwillbelarger;weneedtocontrolhowmuchlargeritwillbe.A®rstpossibilityistomarkonlythestartingpositionofeachblock.Anexperimenton100randompositionsforthebasicvarianthasshownthattheratioRisabout3:95,whichistoomuch.Asecondpossibilityistomarkonlythepositionsthatcanbereachedfromtheinitialpositionoftheblockbymakingmovesinonlyoneofthefoursequencesoftheblocksimultaneously.Geometrically,thosearethepointslocatedonthefouredgesoftheblockstartingfromtheinitialposition.TheratioRdropsdownto1.33,whichisacceptablealthoughabettercompromiseprobablyexists.5.ExperimentalResultsThemethodwasdesignedtobecomplete;wehaveveri®edexperimentallythatitisindeedthecase.Thisisasignthatwehavecorrectlyanalysedallthepossibleinteractionsthatcanoccurattheboundariesoftheblocks.Themethodforverifyingthecompletenesswasthefollowing:fromaninitialposition,®rstrunacompletedepth-®rstsearchandstoreallthepositionsofthesearchspace;thenrunablocksearchandverifythatallthepositionsofthesearchspacelieinatleastoneoftheblocks.Thisveri®cationhasbeendonefor1000initialpositions.Table2showsstatisticsaboutanexperimenton1000randominitialpositionsforthebasicvariant.ThereisadifferenceintimeandnumberofpositionscomparedtoSubsection3.1becausethesearchisnotstoppedwhenwe®ndawinningposition.Alsothetranspositiontableisnotimplementedinthesameway:beforeitcouldgrowasneeded,nowweuseahashtableof®xedsizeas 356B.Helmstetter,T.Cazenaveisusualingameprogramming(Breuker,1998).Thehashtablehas64millionentries.avg.numberofpositionsforDFS502,000avg.numberofblocks36,200avg.sizeofblocks18.6R1.34avg.timeforDFS2.28savg.timeforblocksearch2.04sTable2.Basicvariant(4suits,13cards/suit).Theaveragesizeoftheblocksis18.6,soonenodeofblocksearchdoesasmuchworkas18.6nodesofDFSinaverage.Aswehavealreadymentioned,theto-talnumberofpositionsinalltheblocksislargerthanthenumberofpositionssearchedbyDFS,byabout34%.The®nalresultinspeedisagainof11%forblockssearch.Inthepresentcasehowever,thedifferenceintimeisnotverysigni®cantoftheperformanceofblocksearchbecause,forbothalgorithms,muchtimeisspentreinitializingthelargetranspositiontablebetweenproblems.Wedonotseethepowerofblocksearchyet.Highergainsinspeedcanbeobtainedinvariantswithalargersearchspace,andwithahigherdegreeofindependencebetweenthesubgames.Thiscanbeachievedbyincreasingthenumberofcards.Wethereforeturnto6suitsand13cardspersuit.Thisincreasesboththenumberofcardsandthenumberofsubgames.numberofpositionsforDFS289106numberofblocks5:00106sizeofblocks59.7R1.03timeforDFS437stimeforblocksearch44sTable3.6suits,13cards/suit,thehashtablehas64millionentries.Itisdif®culttogiveaveragestatisticsbecausethesizeoftheproblemsvaryagreatdeal,somebeingtoobigforDFSandafewevenforblocksearch.Wehavemade15experimentswithini-tialpositionsthatcouldbecom-pletelysearchedbothwithblockssearchandDFS.InTable3weshowdetailedstatisticsforoneofthem,whichistypical.WealsoshowinFigure7thatthegaininspeediscorrelatedtothesizeofthesearchspace.This 2 4 6 8 10 12 14 16 18 20 22 1e+07 1e+08 1e+09 1e+10gain in speednumber of positions for DFSFigure7.GaininspeedofblocksearchoverDFS,for15initialpositions. SearchingwithAnalysisofDependenciesinaSolitaireCardGame357ispromising.Ouralgorithmclearlyhasanadvantageoveradepth-®rstsearchbecauseitcanbuildlargeblocks,andthisadvantagewouldgrowlargerifthenumberofsuitsand/orcardspersuitwasfurtherincreased.numberofpositionsforDFS1550106numberofblocks5:88106sizeofblocks61.1R0.23timeforDFS1730stimeforblocksearch46sTable4.6suits,13cards/suit,thehashtablehas8millionentries.IntheexperimentofTable3,theratioRhasdroppeddownfrom1.34to1.03.Thisisduetocollisionsinthetranspositiontable.Thisphenomenonisam-pli®edifwedecreasethesizeofthetranspositiontable:Table4showsstatisticsaboutthesameproblembutwithahashtablethatcanonlycontain8Mpositions.ThishasadramaticeffectonDFS,butalmostnoeffectonouralgorithm.Becauseofcollisions,theratioRisevenlessthan1!So,nowthesituationisreversed:itisouralgorithmthatmakesabetteruseofthetranspositiontable.6.PerspectivesWeconcludethepaperbyprovidingtwoperspectives.InSubsection6.1possibilitiesforgeneralizationaregiven.InSubsection6.2dependency-basedsearchiscomparedtoblocksearch.6.1PossibilitiesforGeneralizationThegeneralideaofthemethoddoesnotrelymuchonthedomainofGaps.Ournotionofablockcaninprinciple®ndequivalentsinmanydomains,pro-videdthatwegeneralizeitalittle.Untilnowwehaveworkedwithblocksthatareproductsofindependentsequences;asa®rstgeneralization,weshouldde®neblocksasproductsofindependentgraphs.Inmostdomainstherewillbepartsoftheproblemthatwillbe,atleastlocally,relativelyindependent.Toapplythemethod,wemustde®newhatasubgameis,bystatingwhichmovesbelongtowhichsubgame,andwemustanalysepreciselyallkindofinteractionsthatcouldoccurbetweenthem.Thisanalysisisdif®cultandisdomain-dependent,butthentherestissimilartowhatwedidinGaps:buildandextendsubgraphsineachsubgameonlyaslongastheykeepbeingindependent.Theproductofthosegraphsgivesablock.Thenwebuildnewblocksattheboundaryofthisblockandsearchthemrecursively.Thereforeweclaimthattheideaofdecomposingthesearchspaceinblocksisanaturalwaytosimplifythesearchspaceandmaybeapplicabletootherdomains.Furthermore,themethodcouldbemuchmorepowerfulindomainswithmoreindependencebetweensubproblems,leadingtotheconstructionofmuchlargerblocks. 358B.Helmstetter,T.Cazenave6.2ComparisonbetweenDependency-basedSearchandBlockSearchAsa®rstapplicationdomaintodependency-basedsearch,Allis(1994)con-sideredthedoubleletterproblem.Inthisdomain,astateconsistsinawordonthesetof5lettersfa;b;c;d;eg.Anydoubleoccurrenceofalettercanbereplacedbyasingleinstanceofitsalphabeticalpredecessororsuccessor.Thealphabetiscyclicsoeecanbereplacedeitherbydora,aabyeithereorb.Thewinningstatesaretheone-letterwords.AdetailedapplicationofthemethodhadbeenshownbyAllisfortheinitialstateaaccadd.Asolutionexists(thelettersthatchangehavebeencapitalized):aaccadd!Bccadd!bBadd!Aadd!Edd!eE!AWearegoingtocomparethewaythisinstanceissolvedbydependency-basedsearch(accordingtoAllis)andawayitcouldbesolvedbyablocksearchalgorithm.Dependency-basedsearchrunswithasuccessionofdependencystagesandcombinationstages.Afteronedependencystageandonecombina-tionstage,hegetsthegraphinFigure8:heconsidersthe6movespossibleattherootand®ndsthattwocanbecombinedtogether.Thesamesituationcanberepresentedwithblocks(Figure9):wehave3independentsubgamescorre-spondingtothelettersatthepositions1;2,3;4and6;7,respectively.Ineachofthosesubgamestwomovescanbemadefromtheinitialposition.Thereforethesetofpositionsreachablewiththesemovescanberepresentedwithacube,theinitialpositionaaccaddbeinginthecentre.Wethen®ndaninteractionatoneoftheedgesofthecube:thetwo“B”thathavebeencreatedallowtomoveinanewsubgameandthereforeanewblockcanbeconstructed.EccaddBccaddaaBaddaaDaddaaccaCaaccaEaaccaddBBadd1st dependency stage1st combination stageFigure8.Dependency-basedsearch,beginning.Therestofthesearchcontinuessimilarlywithdependency-basedsearch(Figure10)andblocksearch(Figure11).Atleastinthisexamplewearereallydoingthesamethingwithdifferentrepresentations.Thisgoestoshowthatbothmethodshavesimilarities.However,therearesomedifferencesthatcannoteasilybeseenonthelastexample.Firstwedonotseeallthepowerofblocksearchhere:comparativelytodependency-basedsearch,webelieveitcandealwithinteractionsofamorecomplicatednature(asinGapswherewecouldnotapplydependency-basedsearch).Probablywe SearchingwithAnalysisofDependenciesinaSolitaireCardGame359BccaddEccaddaaccaDaaccaEaaDaddaaBaddBBaEBBaDBBadda new block can be constructed from this edgeinitialpositionaaccaddFigure9.Blocksearch,beginning.EccaddBccaddaaBaddaaDaddaaccaCaaccaEaaccaddBBaddAaddCaddEddBddEEADFigure10.Dependency-basedsearch,complete.EddBddDABccaddEccaddaaccaDaaccaEaaDaddaaBaddCaddAaddaaEBBaddaaccaddFigure11.Blocksearch,complete.donotseeallthepowerofdependency-basedsearcheither.Forinstanceandincontrarytoblocksearch,itisnotnecessarytoprovideanexplicitdecompositioninsubgamestoapplydependency-basedsearch.7.ConclusionWehavepresentedseveralsearchalgorithmsthattakeadvantageofthepar-ticularitiesofthegameofGaps.Ourworkhasresultedinamethod,blocksearch,whichmaybeapplicableinotherdomains.Wehaveshownthatiterativesamplingproducesgoodresults,eitherforthebasicvariantorthecommonvariant.Conversely,wehaveshownthattheuseofheuristicsisnotsopromising.Thereforewecoulddealwithonlyoneprobleminisolation:exploitingtheindependencebetweenpartsofthegame.ExistingmethodsthatdealwiththisproblemwereeithernotapplicabletothedomainofGapsorwerenotaspreciseasours. 360B.Helmstetter,T.CazenaveBlocksearchisamethodtotakeadvantageofadecompositioninsubgameswhenthereareinteractionsbetweenthosesubgames,whilekeepingthesearchcomplete.Itimpliesanalysingtheoreticallyalltypesofinteractionsthatcanoccur:howtodetectthem,howtodealwiththembybuildingnewblocksattheboundaryofthecurrentblock.Althoughthisanalysisreliesondomain-dependentknowledge,thegeneralideaofthemethoddoesnot.Experimentalresultshaveshownthatlargegainsinspeedoveradepth-®rstsearchcanbeexpected,dependingontheaveragesizeoftheblocksweareabletobuild.Speci®cally,themethodcanbeusedtosolvepositionsofthebasicvariantofGapswithmorecards.Becausethemethodsimpli®esthesearchspace,italsomakesbetteruseofatranspositiontable.ReferencesAllis,L.V.(1994).Searchingforsolutionsingamesandarti cialintelligence.Ph.D.thesis,RijksuniversiteitLimburg,Maastricht.Anshelevich,V.V.(2002).Ahierarchicalapproachtocomputerhex.Arti cialIntelligence,Vol.134,Nos.1-2,pp.101-120.Berliner,H.(1997).Researchinterests.http://www-2.cs.cmu.edu/burks/frg97-98.html.Botea,A.,Muller,M.,andSchaeffer,J.(2002).Usingabstractionforplanninginsokoban.InProceedingsofComputersandGames,Edmonton,Canada.Bouzy,B.(1997).Incrementalupdatingofobjectsinindigo.InProceedingsoftheFourthGameProgrammingWorkshopinJapan.Breuker,D.M.(1998).Memoryversussearchingames.Ph.D.thesis,UniversiteitMaastricht,Maastricht.Cazenave,T.(2002).Ageneralizedthreatssearchalgorithm.InProceedingsofComputersandGames,Edmonton,Alberta.Harvey,W.D.andGinsberg,M.L.(1995).Limiteddiscrepancysearch.InProceedingsofIJCAI,Vol.1,pages607-615.Hoffmann,J.(2001).Localsearchtopologyinplanningbenchmarks:Anempiricalanalysis.InProceedingsofIJCAI,pages453-458.Junghanns,A.andSchaeffer,J.(2001).Sokoban:improvingthesearchwithrelevancecuts.TheoreticalComputerScience,Vol.252,Nos.1-2,pp.151-175.Shintani,T.(1999).AProgramtosolveSuperpuzz.InGameProgrammingWorkshopinJapan'99,pages84-91,Kanagawa,Japan.(InJapanese)Shintani,T.(2000).ConsiderationaboutstatetransitioninSuperpuzz.InInformationProcessingSocietyofJapanMeeting,pp.41-48.Shonan,Japan.(InJapanese)

Related Contents


Next Show more