Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
GameTheory
[AnilKishore] student,IIITHyderabad,India.
GeneralGameSetting
TwoplayersAandB Rulesofthegame:
Possiblemovesaplayercantakeinhis/herturn Winningcondition
FirstGame:BowlingPins
Nbowlingpinsarrangedinarow PossibleMoves
Winner:Onewhoknocksdownthelastpin GivenN,whowinsifAtakesthefirstmove?
Solution:FirstGameBowlingPins
StoneGame:RESN04onCodeChef
Solution:StoneGame
WinLoseBruteforceStrategy
1.Allterminalpositionsarelosing. 2.Ifaplayerisabletomovetoalosingpositionthenhe isinawinningposition. 3.Ifaplayerisabletomoveonlytothewinning positionsthenheisinalosingposition.
boolean isWinning( position X ) { for (all positions Y that I can go to) if ( !isWinning(Y) ) return true; return false;
Game:Takeaway134
Solution:Takeaway134
11iswinningposition
Game:Takeaway1toK
Solution:Takeaway1toK
L O S E
W I N
TheGameofNIM
GivensizesofNheapsofstones
Solution:NIM
L O S E
W I N
NewStoneGame
Solution:NewStoneGame
Idea:Frompilei,wecanremove1*ior2*ior3*i....or(S[i]/i)*istones LooksexactlylikeNIMwithheapsize(S[i]/i)
int r = 0; for (int i=1; i<=N; i++) { r ^= piles[i]/i; } puts( r==0 ? BOB : ALICE );
THEGAME:Quark'10BitsGoa
TomandHanksplaythefollowinggame.Onagameboard havingalineofsquareslabelledfrom0,1,2...certainnumber ofcoinsareplacedwithpossiblymorethanonecoinona singlesquare.Ineachturnaplayercanmoveexactlyone cointoanysquaretothelefti.e,ifaplayerwishestoremove acoinfromsquarei,hecanthenplaceitinanysquarewhich belongstotheset(0,1,...i1).Giventhedescriptionofthe boardandalsoassumingthatTomalwaysmakesthefirst moveyouhavetotellwhowinsthegame(AssumingBoth playOptimally). BoardsizeN(1<=N<=105).
Numberofcoinsoneachsquare:X(0<=X<=105)
Solution:THEGAME(QCJ6inCodeChef)
TakeHomeGames (Notsomegamecategory:p,trytheseoutinyourrooms)
References&furtherplaying
Thatsallfolks...HappyGaming!