peter van emde boas: what is the size of a game ? games and complexity 2011 what is the size of a...
TRANSCRIPT
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
What is the size of a Game ?
Peter van Emde Boas
Bronstee.com Software & Services B.V.
ILLC-FNWI-Univ. of Amsterdam
Roger van der Weyden: Last Judgement, Hospices Civils de Beaune, France
References and slides available at: http://staff.science.uva.nl/~peter/teaching/gac11.html
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Hoe lang is een Chinees ?(How long is a Chinese?)
Hu Liang is een Chinees
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Games and Computer Science
• You can design or play (computer) games– but that’s not the purpose of this course
• You can ask questions about games– which may guide you to some interesting Mathematics
• You can answer such questions using a Computer– which is done in a special branch of AI but not in this
course
• You can use Game based models when solving Computer Science Questions– we shall encounter some examples in this course
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
© Games Workshop © Games Workshop
URGATOrc Big Boss
THORGRIMDwarf High King
Introducing the Opponents
Games involve strategic interaction ......Games involve strategic interaction ......
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
A Game….
X
X
O
Questions: Will the Game terminate ?
Can somone win the Game ?
If So: Who ?
Victorious Warriors win first and then go to War, while defeated Warriors go to War first and then seek to win.
Sun Tzu, the Art of War.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
A Game….
X
X
O
Questions: Will the Game terminate ?Trivially YesCan somone win the Game ?
If So: Who ?
Victorious Warriors win first and then go to War, while defeated Warriors go to War first and then seek to win.
Sun Tzu, the Art of War.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
A Game….
X
X
O
Questions: Will the Game terminate ?Trivially YesCan somone win the Game ?If both play well a draw resultsIf So: Who ?
Victorious Warriors win first and then go to War, while defeated Warriors go to War first and then seek to win.
Sun Tzu, the Art of War.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Another Game
from H.W. Lenstra: Aeternitatem Cogita
Questions: Will the Game terminate ?
Can somone win the Game ?
If So: Who ?
white to move and wins
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Another Game
from H.W. Lenstra: Aeternitatem Cogita
Questions: Will the Game terminate ?The rules make it soCan somone win the Game ?Unknown until todayIf So: Who ?
white to move and wins
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Ganzenborden• may terminate in an unexpected state
Ghica in pit
Peter in jail
Termination is not guaranteed; all players may be killed by the hunter over and over again.....
There is no strategy in this game; Random moves only
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
the game of NIM
Skavenslaves© the Games Workshop
Plague Monks© the Games Workshop
Clanrat Warriors© the Games Workshop
URGAT© the Games Workshop
THORGRIM© the Games Workshop
TURN:1: select a group of prisoners2: feed some of them ( ≥ 1) to the Ogres3: if no prisoners remain you loose
© the Games Workshop
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
The game of NIM
Positions are determined by the sizes of the piles( 24, 14, 15 ) in the exampleNim-sum of these numbers in binarydetermines whether position is won or lost
24 = 1 1 0 0 014 = 0 1 1 1 015 = 0 1 1 1 1sum = 1 1 0 0 1
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
A Game in Mathematics
Position: a finite list of non-negative numbers:
5, 5, 3, 4, 0, 1, 12
Move: Replace a single number by a finite list of smaller numbers ( 0 only may be removed )
5, 3, 3, 2, 0, 3, 4, 0, 1, 12
Player unable to move looses the game.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions about this game in mathematics: Will it terminate ?
Can one of the players win ?
If so: Which Player ?
And what strategy should the winner use ….?
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions about this game in Mathematics: Will it terminate ?Yes: but to see this requires more advanced set theory(or use a cleverly designed lexicographical order)
Can one of the players win ?Yes: but this game is not covered by Zermelo's theorem
If so: Which Player ?A simple parity argument works here: There must exist anumber with an odd number of occurrences in order to win.
And what strategy should the winner use ….?Use the largest number with an odd number of occurrencesand make the number of occurrences of all numbers even.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
CONWAY’S PERSPECTIVE
© Peter van Emde Boas 19761208 @ SMC, Amsterdam
© Peter van Emde Boas 19761208 @ SMC, Amsterdam © Peter van Emde Boas 19761208 @ SMC, Amsterdam
A Game isa Set.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
A GAME IS A SET
• Pick an element, this is again a set
• Give it to the other player, it is now his turn
• Player looses if there is no element remaining: the empty set represents the (unique) lost game
• Let’s play REALS !
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
The game REALS• real r = Dedekind Cut < L,R >• L, R subsets of rationals Q such that .....• rational q is equiv. class of fractions• fraction t/n is ordered pair of integers• integer z is equiv. class of differences• difference a - b is ordered pair of
naturals• natural n = { 0, 1, .... , n-1 } ; 0 = • ordered pair < a,b > = {{a},{a,b}}
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Another way of playing multisets
• A position is a finite collection of sets, repetitions allowed (multiset)
• A move consists of– Select one of the sets– Replace this set by a finite collection of
its elements, repetitions allowed
• The player unable to move looses• Why does this game terminate?
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Playing Multisets
{ A, A, B, B, B, C , D , E }
( B = { p, p, q, r, r, s, t } )
{ A, A, B, B, p, q, q, s, s, t, C , D , E }
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Playing Multisets
Game tree of the multiset game becomes infinite
Tree representing an individual play of the multisetgame is both Finitely Branching (due to the rules)and anti-well founded (due to well foundedness of sets)and therefore Finite on behalf of Königs Lemma
Therefore the multiset game terminates.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Napoleon PatienceTake a deck of cards, and place them randomly in 4 rows of 13 cards each.Next pick the four aces and place them in a random orderat the front of the four rows.This is the initial position.
Subsequently you may move a non-ace card behind itspredecessor, provided there is a gap in the row there(but a row's lenght never should exceed 14).A gap behind a King can't be filled; therefore a positionwhere no move is possible can arise.....You win if you reach a position where all rows are ordered.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Napoleon Patience
Gaps before moving Aces
Gaps during game
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions about Napoleon Patience: Will the game terminate ?
Is there a player who can win ?
If so, who ?
What strategy should the winner use ….?
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions about Napoleon Patience: Will the game terminate ?Not at all evident; why can't a position be repeated there is something to prove here.....
Is there a player who can win ?Meaningless question; it's a solitaire game;The question is whether you can always win this game ?
And can you ?With bad luck NO; all Aces may be placed after Kings initially
What strategy should the winner use ….?I have no idea ....
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Termination proofAssign to every occurrence of card j directly followingcard j-1 of the same suit a value of 14 - j points.The value of a position is the sum of all points assigned to the 4 * 13 adjacent pairs on the board.
It is not hard to see that every move will strictly increasethe value of a position ( by at least one point )
The desired target position has the maximal value possible( 4 * (12 * 13 / 2) ) = 312 points.
This yields also an upper bound on the number of consecutive moves possible.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
L-game E. de Bono
Popular psychology from the early seventies
The companion book “the five day course ofthinking” introduces the L-game as a training tool
I hate psychology
Therefore:
Let’s kill this game by solving it on a computer.
Project performed in 1976 by: V.W. Gijlswijk, G.A.P. Kindervater, G.J. van Tubergen & J.J.O.O. Wiegerinck
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
de Bono’s L-GameBoard: 4 by 4 square
Pieces: Red’s L-piece Green’s L-piece 2 Neutral stones
Source: van Gijlswijk et.al.: Computer Analysis of E. de Bono’s L-GameRep. MI-UvA-76-18
Move: 1) remove your L-piece, and place it somewhere else2) may move one of the neutral stones
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
de Bono’s L-GameBoard: 4 by 4 square
Pieces: Red’s L-piece Greens’s L-piece 2 Neutral stones
Source: van Gijlswijk et.al.: Computer Analysis of E. de Bono’s L-GameRep. MI-UvA-76-18
Move: 1) remove your L-piece, and place it somewhere else2) may move one of the neutral stones
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
de Bono’s L-GameBoard: 4 by 4 square
Pieces: Red’s L-piece Green’s L-piece 2 Neutral stones
Source: van Gijlswijk et.al.: Computer Analysis of E. de Bono’s L-GameRep. MI-UvA-76-18
Move: 1) remove your L-piece, and place it somewhere else2) may move one of the neutral stones
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
de Bono’s L-GameBoard: 4 by 4 square
Pieces: Red’s L-piece Green’s L-piece 2 Neutral stones
Source: van Gijlswijk et.al.: Computer Analysis of E. de Bono’s L-GameRep. MI-UvA-76-18
Move: 1) remove your L-piece, and place it somewhere else2) may move one of the neutral stones
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
de Bono’s L-GameBoard: 4 by 4 square
Pieces: Red’s L-piece Green’s L-piece 2 Neutral stones
Source: van Gijlswijk et.al.: Computer Analysis of E. de Bono’s L-GameRep. MI-UvA-76-18
Move: 1) remove your L-piece, and place it somewhere else2) may move one of the neutral stones
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Move / Lost position
Complete move for Red
Lost Position for Green Initial position
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions on the L-Game: Will the game terminate ?
Can one of the players force to win the game ?
If so: Which Player can win the game ?
And what strategy should he use
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions on L-Game: Termination ?No - The game can run in a cycle forever....
Can a player force to win ?In some position yes, but not in the initial position
If so: Which player?The game in the initial position is a draw
Strategy ….?Hard to see; there exists a database for playing this game,printed in the report mentioned below.
Source: van Gijlswijk, J.J.O.O Wiegerinck et.al.: Computer Analysis of E. de Bono’s L-GameRep. MI-UvA-76-18
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Lets use a Computer…
In order to answer these questions using a computeryou should tell the computer first what is the game he is supposed to analyse ….
How to represent a Game in a Computer ?
Which leads to the problem of finding good formalmathematical models for Games.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Extensive format: Game Tree
initial position
end position
Red to move
Green to move
end position
Winner explicitly mentionedat terminal positions
R
RG
G
R
GR
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Backward Induction
end position
Red to move
Green to move
end position R
RG
G
R
GR
R
R
GG
G
Both players choseeverywhere theiroptimal moveinitial position
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Zermelo’s Theorem
Zermelo's Theorem Is based on a sufficient condition for making the Backward Induction Algorithm work:
In a finite two-person game where a draw is impossible one of the two players must have a winning strategy
Originally proposed to solve the Chess Game
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
The game of HEX
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
The game of HEX
Red and Green alternatively colour one cell usingtheir own color.
The first player connecting both side regions with his color by a continuous path in his color wins thegame
Green is the first to move
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
In this position Green wins the game
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Green has won the Game…
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions about HEX: Will the game terminate ?
Is there a player who can win ?
If so, who ?
What strategy should the winner use ….?
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Why is a Draw impossible?
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions about HEX: Will the game terminate ?Trivially; Yes
Is there a player who can win ?Yes; Zermelo's Theorem tells us so, since draws areimpossible
If so, who ?It must be Green (first player); otherwise a contradictionarises (strategy stealing argument).
What strategy should the winner use ….?Still Unknown
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Backward induction on Game Graphsstart
RG
Initial labeling:only terminal positionsare labeled. Player unable tomove looses
start
RG
Final labeling:iterative apply BI rulesuntil no new nodes arelabeled. Remaining nodes are Draw D
D
R
G
G
G
R
R
RR
D D
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
A Game
© Donald Duck 1999 # 35
Starting with 15 matchesplayers alternatively take1, 2 or 3 matches away untilnone remain. The playerending up with an oddnumber of matches winsthe game
A Game specified by describing A Game specified by describing the rules of the game ....the rules of the game ....
redgreen
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Questions about this Game
• What if the number of matches is even?
• Can any of the two players force a win by clever playing?
• How does the winner depend on the number of matches
• Is this dependency periodic? If so WHY?
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Analysis of the DD gameExtension used:Red wins if he hasan odd number when thegame terminates.This allows for even n .
Four types of configurations remain:R/E : Red has to play and has an even numberR/O : Red has to play and has an odd numberG/E : Green plays, while Red has an even numberG/O : Green plays, while Red has an odd number
Relevant feature: parity of number of matches collectedso far (not the number itself!)
redgreen
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Backward Induction Tablen G / E G / O R / E R / O
18 G G R / 1 R / 217 G R R / 1 G16 G R G R / 315 G G R / 2 R / 314 G G R / 2 R / 113 R G G R / 112 R G R / 3 G11 G G R / 3 R / 210 G G R / 1 R / 2 9 G R R / 1 G 8 G R G R / 3 7 G G R / 2 R / 3 6 G G R / 2 R / 1 5 R G G R / 1 4 R G R / 3 G 3 G G R / 3 R / 2 2 G G R / 1 R / 2 1 G R R / 1 G 0 G R G R
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Bi-Matrix Game / Strategic Form
© Games Workshop © Games Workshop© Games Workshop© Games Workshop
© Games Workshop© Games Workshop
Runesmith Dragon SquiggOgre
R
D
O S
1/-1
1/-1
-1/1
-1/1
A Game specified by describing A Game specified by describing the Pay-off Matrix ....the Pay-off Matrix ....
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Von Neumann’s Theorem
( )/2 :+ ( )/2+© Games Workshop © Games Workshop© Games Workshop© Games Workshop
© Games Workshop© Games Workshop
R D SO
R
D
O S
1/-1
1/-1
-1/1
-1/1
Mixed Strategy Mixed Strategy Nash EquilibriumNash Equilibrium; ; no player can improve his pay-off by deviation.no player can improve his pay-off by deviation.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
My first encounter with Game Theory
December 1962
Anatol Rapoport
Inventor ofTit for Tat
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Strategic (bi-Matrix) Form Games
Players : finite set of agents
Strategies: finite set for each player
Strategy profile: each player chooses a strategy
Pay-off: given the strategy profile each player collects some pay-off value (utility, outcome)
Preference: Each player has a preference order for outcomes
The favoured model for Game theory in Economics
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Tosca and the prisoners Dilemma
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
WHY WORRY ABOUT MODELS?
Algorithmic problem
Instances
Solutions
InstanceFormat
Question
Instance Size
Algorithm Space/TimeComplexity
The rules of the game called “Complexity Theory”
MachineModel
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Format and Input SizeThink about simple games like Tic-Tac-ToeNaive size of the game indicated by measures like:
-- size configuration ( 9 cells possibly with marks)-- depth (duration) game (at most 9 moves)
The full game tree is much larger : ~986410 nodes(Size of the strategic form beyond imagination.....)
What size measure should we use for complexitytheory estimates ??
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
The Impact of the FormatThe gap between the experienced size and the size of the game tree is Exponential !
(Another Exponential Gap between the game tree and the strategic form.)
These Gaps are highly relevant for Complexity!
The Challenge: Estimate Complexity of Game Analysis in terms of Wood Measure.
Wood Measure : configuration size & depth
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
REASONABLE GAMESFinite Complete Information (Zero Sum)
two player games (probabilistic moves allowed)
Structure: game tree T given by intensional description X, properties like:
is p a legal position ?, is p terminal ? is p initial ?, who must move in p ?,
which moves are allowed in p?what are predecssor positions of p
are simply decidable problems (P-time in X)One can traverse the game tree T in time
proportional to the size of T .....
The game duration must be polynomial in X.X : “Wood Measure”
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Extension of this classFinite Complete Information (Zero Sum)
two player games (probabilistic moves allowed)
Structure: game graph G given by intensional description X, properties like:
is p a legal position ?, is p terminal ? is p initial ?, who must move in p ?,
which moves are allowed in p?what are predecssor positions of p
are simply decidable problems (P-time in X)One can search the game graph G in time
proportional to the size of G .....
The game duration must be polynomial in X.X : “Wood Measure”
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Decision problems
Termination
(Bi-matrix format: No Problem !Extensive: Reachability Analysis - Graph TraversalNaive: Implicite traversal
Trivial for finite game trees…..
Complexity: proportional / polynomial in the numberof nodes in the game graph.
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Decision ProblemsDetermination of winner
(Bi-matrix format: Just read the matrix !)Extensive: Backward Analysis - Graph TraversalNaive: Backward Analysis - Implicite traversal
Complexity: proportional / polynomial in the numberof nodes in the game tree for the tree case.General graph: ~ number of nodes + number of edges
Recursive backward analysis of game tree:Memory size: ~ woodmeasure * duration game
THIS WILL BE THE THEME OF FUTURE CLASSES
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
ConclusionsThe Strategic Bi-matrix format is useless for algoritmicgame analysis and irrelevant.
Reasonable games can be exponentially large in theWood measure; Still recursive backward analysis in PSPACE is a possibility.
Reductions can be used to establish correspondingPSPACE lowerbounds; which proves PSPACE completeness
Among the given examples the “Mathematical” game isdeviant: it is infinite (but its analysis is trivial….)
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
Choice of model depends on perspective:What aspect of games do you want to model/investigate ??
E.G., the Strategic Form is OK if your interest is thestudy of solution concepts in Game Theory....
How Large is a Game
Exponential gaps between the sizes of the different models are a fact of life
“how large” thus becomes a game, like other partsof mathematics …..
Peter van Emde Boas: What is the size of a game ? Games and Complexity 2011
GAME OVER
© Morris & Goscinny