Game Theory
Game Theory
Game Theory
Telerik Software
Learning
&
Academy
http://academy.telerik.com
Development Team
2.
3.
Game States
Turns; P, N positions
Optimal play
"Scoring" game example
4.
Composite games
Tweedledum & Tweedledee
principle
Sprague-Grundy Theorem
5.
Of conflict
Of cooperation
Between intelligent decision makers
Game Theory
Concepts
Combinatorial Games
Impartial, Partizan and Play Types
Combinatorial Games
Combinatorial Game
Examples
Partisan games
Different moves available to different
players
Chess, Checkers, Tic-Tac-Toe are
partisan
Impartial games
Different players have the same moves
Examples Nim, Quarto
Combinatorial Games
14
Blue
"thinks
"
Yellow
moves
Yellow
"thinks
"
Blue
moves
Blue
"thinks
"
Yellow
"thinks
"
Position of a player
Depends on the positions of all the
chips
Considered in the "think" stage
Immediately after the other player
moved
Immediately before the current
player moves
16
Game of Scoring
19
Game of Scoring
Demo
20
Game of Scoring
Positions
0 losing (P-position)
1, 2, 3 winning positions (Npositions)
We can immediately move the chip
to 0
4 losing position (P-position)
We place chip at 1, 2 or 3 and other
player wins
5, 6, 7 winning positions (Npositions)
Can place other player in a losing
position (4)
21
Generalization of
Positions
N-position
There isalwaysat
least one option
that leads to aPposition
22
Solving Scoring in C+
+
Live Demo
Nim
Nim Demo
index
5
27
Nim Observations
28
Nim More
Observations
What happens for Nim with 1element heaps mixed with 2-element
heaps?
a) (1, 2) first player wins (winning
position)
first player can reduce 2 to 1
player 2 forced into (1, 1), which is
losing
Nim General
Observations
30
Nim-sum
31
Nim-sum Why it
Works
(k
32
Nim-sum Finding
Positions
33
Nim Importance
35
Nim Importance
36
Nim Importance
index
5
37
Composite Games
Dividing into Subgames,
Tweedledum & Tweedledee
Principle, Sprague-Grundy
Game of Scoring
Demo
39
Composite Games 2
Chips
40
Composite Games
Solving
Calculating the
Sprague-Grundy
Function
Follower positions,
Minimal excludent
Calculating SG function
Sprague-Grundy function
Recursively generates "Grundy"
values/numbers
Numbers correspond to heap sizes
in Nim
Adapt to specific game through
Follower function
Mex function
43
Calculating SG function
g Sprague-Grundy function
F follower function
Mex minimal excludant
p and q two game positions
44
Calculating SG function
Calculating SG function
46
Calculating SG
example
Grundy values
g(0)
with Scoringg(1)
= 0, by definition.
= 1 since F(1) = {0}.
Losing
g(2) = 2 since F(2) = {0,
positions in
g(3) = 3 since F(3) = {0,
a game have
g(4) = 0 since F(4) = {1,
g() = 0
- The values of g on F(4)
Here, cant and the minimum that does
there is 0.
move from 0,
so we lose g(5) = 1 since F(5) = {2,
- The values of g on F(5)
there and and the minimum that does
there is 1...
g(0) = 0
Index
0
1
2
3
4
SG value
1}.
1, 2}.
2, 3}.
are {1, 2, 3}
not appear
3, 4}.
are {2, 3, 0}
not appear
5
1
47
Calculating SG
pseudocode
Solving Composite
Games Using SG & Nim
49
Solving
Multi-Chip Scoring
in C++
Live Demo
Conclusion
What we covered
Impartial games
Winning and losing positions (N and
P)
Nim and representing impartial
games as Nim
Sprague-Grundy theorem & function
Solving composite games
51
Conclusion
Game Theory
?
?
?
?
,
SEO -
,
, HTML, CSS, JavaScript, Photoshop
free C# book, C#, Java, C#
" "
" cloud "
Questions?
http://algoacademy.tele