Professional Documents
Culture Documents
Legantis Final Report Experimentation
Legantis Final Report Experimentation
Combinatorial Games
STEI01
Signature: Q. Legnthc
By Christos Legantis
Registration Number: 201415575
April 2, 2018
Contents
1 Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 Report Structure . . . . . . . . . . . . . . . . . . . . . . . 5
4 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Problem Description and Specification . . . . . . . . . . . 7
5.1 Problem Description . . . . . . . . . . . . . . . . . . . . . 7
5.2 Games’ Description . . . . . . . . . . . . . . . . . . . . . . 7
5.2.1. Grundy’s Game . . . . . . . . . . . . . . . . . . . . 7
5.2.2. Differences Game . . . . . . . . . . . . . . . . . . . 7
5.2.3. RemoveDigits Game . . . . . . . . . . . . . . . . . 7
5.2.4. MoveAnyMatches Game . . . . . . . . . . . . . . . 7
5.3 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . 8
6 System Design . . . . . . . . . . . . . . . . . . . . . . . . . . 9
7 Detailed Design and Implementation . . . . . . . . . . . . 10
7.1 Grundy’s Game . . . . . . . . . . . . . . . . . . . . . . . . 10
7.2 Differences Game . . . . . . . . . . . . . . . . . . . . . . . 10
7.3 RemoveDigits Game . . . . . . . . . . . . . . . . . . . . . . 11
7.4 MoveAnyMatches Game . . . . . . . . . . . . . . . . . . . 11
8 Results and Evaluation . . . . . . . . . . . . . . . . . . . . . 12
8.1 Grundy’s Game . . . . . . . . . . . . . . . . . . . . . . . . 12
8.1.1. Results . . . . . . . . . . . . . . . . . . . . . . . . . 12
8.1.2. Analysis . . . . . . . . . . . . . . . . . . . . . . . . 12
8.2 Differences Game . . . . . . . . . . . . . . . . . . . . . . . 12
8.2.1. Results . . . . . . . . . . . . . . . . . . . . . . . . . 12
8.2.2. Analysis . . . . . . . . . . . . . . . . . . . . . . . . 13
8.3 RemoveDigits Game . . . . . . . . . . . . . . . . . . . . . . 15
8.3.1. Results . . . . . . . . . . . . . . . . . . . . . . . . . 15
8.3.2. Analysis . . . . . . . . . . . . . . . . . . . . . . . . 16
8.4 MoveAnyMatches Game . . . . . . . . . . . . . . . . . . . 16
8.4.1. Results . . . . . . . . . . . . . . . . . . . . . . . . . 16
8.4.2. Analysis . . . . . . . . . . . . . . . . . . . . . . . . 17
9 Verification and Validation . . . . . . . . . . . . . . . . . . 22
10 Summary and Conclusions . . . . . . . . . . . . . . . . . . 23
10.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
10.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . 23
10.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . 23
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
1. Abstract
COMBINATORIAL GAMES
CHRISTOS LEGANTIS
4
3. Introduction
3.1. Objectives.
The main aims of this project were to get familiar with impartial (or sym-
metric) combinatorial games, to implement and to mathematically analyse
some of them, known and unknown. There are games in the field of Combi-
natorial game theory that have been already mathematically analysed such
as the game of Nim. However, there are still games that either have not
been mathematically analysed fully yet or they remain unsolved. Some un-
known games, which will be described in detail later in the report, have been
mathematically analysed for this project.
As described in the initial Project scope and Outline plan document, there
were smaller tasks/objectives that had to be met so as to be able to achieve
the main objectives of the project. These were:
• Understand how the general algorithm works and how it can be
applied in different games.
• Implement the general algorithm in an elegant and efficient way to
return correct results fast for big values.
• Choose and implement games from a given list of unknown games
and try to adjust the algorithm to fit the games chosen.
• Explore and find more about the various games by observing the
results of my programs and come up with strict mathematical proofs
of any facts/patterns observed.
3.2. Outcomes.
During the course of this project, fully functional piece of software that gen-
erates all values of positions of a known impartial game and three unknown
games have been implemented. Additionally, strict mathematical proofs have
been written to justify any interesting facts/patterns discovered from the
positions’ values generated from my programs.
5
4. Related Work
As the game of Nim is one of the most popular impartial combinatorial games
it is already implemented and can be found online in different websites such
as:
Archimedes Lab [1]:
Anyone can play the game of Nim online on the Archimedes Laboratory
website. It is implemented a bit differently as the one who picks the last
match loses the game.
Goobix Online Games [2]:
The game of Nim can also be played online on the Goobix website. This is
an implementation of normal play of the game, the player who picks the last
match wins the game.
Cut-The-Knot [3]:
It is an educational website, which deals with different mathematical puzzles
and games. More specifically, in addition to other games it includes many
combinatorial games, some of them being the game of Nim and Grundy’s
game. The games are explained analytically and can be played on the web-
site.
Also, there is some related work in terms of analysing some impartial com-
binatorial games:
Combinatorial Game Theory by Aaron N. Siegel [4]:
In this book a lot of known impartial games such as Nim, Wythoff’s game
and Grundy’s game are analysed. Additionally, it includes the fundamentals
of Combinatorial game theory.
Games of No Chance by Richard J. Nowakowski [5]:
This series of books deals with combinatorial games, gives more informa-
tion and analyses different impartial games. Also, it talks about unsolved
problems in the category of combinatorial games.
Regarding the novel games analysed in this project, there is no related work
specified to these as they are unknown.
6
5. Problem Description and Specification
8
6. System Design
In terms of software, four autonomous helping Java classes have been im-
plemented, one for each game. These generate values for all positions of the
games to help me identify any facts/patterns of the results and in this way
assist my research.
This is an experimental project and as such there is no big system im-
plemented. As aforementioned, a few programs have been constructed to
compute values in the games studied.
9
7. Detailed Design and Implementation
In this section of the report a detailed description of how the games were
implemented will be given.
All four games have a common factor that is taken into account in order to
generate values of all positions. As the Sprague-Grundy theorem states all
impartial games in normal play are equivalent to nimbers, which are the val-
ues of nim piles in the game of Nim.[6][7] Thus, pile sizes in the games should
be mapped to equivalent nim pile sizes. In order to find the value-nimber
of the positions of the games a method called ”minimal excludent”(mex)
is introduced. Mex gets a subset of the values of the positions that can be
reached in a single move from a given position and returns the smallest value
that does not belong to the subset. The value returned is the value of the
position.
11
8. Results and Evaluation
In this section of the report all the facts/patterns observed from the pro-
grams implemented will be listed and proved for each game. First, a de-
scription of the rules of the game will be given. A description of the results
generated and strict mathematical proofs of any facts observed will follow.
As stated before, impartial games in normal play are equivalent to the values
of nim piles in the game of Nim according to the Sprague-Grundy theorem.
Thus, pile sizes in the games are to be mapped to equivalent nim pile sizes.
In order to find these values of the positions of the games the ”minimal
excludent”(mex) method is used. Considering the results of the mex() func-
tion, a value of 0 indicates a losing position for the associated game, while
any positive value indicates a winning position.
8.1.1. Results.
The program implemented to generate the values of each pile size can gen-
erate values for very big pile size such as 100.000 in seconds. Below, in table
1 the first 16 values generated by the program can be seen.
Pile Size 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Value 0 0 0 1 0 2 1 0 2 1 0 2 1 3 2 1 3
8.1.2. Analysis.
Grundy’s game is a very well-known impartial combinatorial ”take and
break” game that has been analysed by a lot of mathematicians. Presently,
the first 235 values have been computed by the German mathematician
Achim Flammenkamp.[8] However, the question whether the sequence of the
Grundy’s values ever becomes periodic is still unanswered and it remains an
unsolved problem.[9] As the main purpose of this project is to research and
analyse unknown impartial games, which have never been analysed before,
no further analysis of the Grundy’s game has been carried out.
8.2.1. Results.
The program implemented generates the values of each position k:n of the
game in seconds. Below, in table 2 a sample of values up to position 10:10
generated by the program can be observed.
12
Piles k,n 1 2 3 4 5 6 7 8 9 10
1 0 1 0 1 0 1 0 1 0 1
2 1 0 2 1 0 0 1 1 0 0
3 0 2 0 2 1 1 0 0 0 1
4 1 1 2 0 0 2 1 1 1 0
5 0 0 1 0 0 1 1 0 1 1
6 1 0 1 2 1 0 0 2 2 1
7 0 1 0 1 1 0 0 1 0 1
8 1 1 0 1 0 2 1 0 2 0
9 0 0 0 1 1 2 0 2 0 1
10 1 0 1 0 1 1 1 0 1 0
1:n 1 2 3 4 5 6 7 8 9 10
1 0 1 0 1 0 1 0 1 0 1
8.2.2. Analysis.
Analysis for positions 1:n
Theorem 8.2. The sequence of the values of positions k:n is periodic with
period 2k.
Proof. For k:n positions with different n we can analyse which moves are
possible:
For n > 2k: In position k:n the difference of the two piles (n − k) will always
be bigger than k if n > 2k. Thus, there is only one possible move; to remove
the size of the smaller pile from the bigger one and therefore to move the
game to position k:(n − k). The fact that there is only one possible move to
be made from this position means that the value of k:n must be less than
2. Namely, since there is only one position available, only one value arises.
If this value is 0 then the value of the original position is 1, otherwise it is
0. Thus, the value of position k:n where n > 2k, is either 0 or 1.
For n = 2k: In position k:2k there are two possible moves available; a)
remove the size of the smaller pile from the bigger (2k −k) and go to position
14
k:k, which is a final and losing position (and has value 0) since no move can
be made b) remove their difference from the smaller pile and go to position
0:2k, which is again a losing position since no move is possible and has a
value of 0. Thus, position k:2k will always be a winning position with a value
of 1 as it would always move the game to a position with value 0.
If n ≥ 3k this means that as mentioned above, there is only one possible
move to be made from position k:n since 3k > 2k; to move the game from
position k:n to k:(n − k). Since there is only one possible position, only one
value arises. If the value of position k:(n − k) is 0 that means that the value
of the original position k:n is 1. In the same way of thinking, since there is
only one possible move, if the value of k:(n − k) is 1, that means that the
value of the original position k:n should be 0.
For n ≥ 4k the value of position k:n will be either 0 or 1 and the value
of k:(n − k) will be the ”opposite” of the value of k:n as explained above.
The only acceptable move from k:(n − k) is to move the game to k:(n − 2k).
Again, depending on the value that k:(n − k) has, the value of k:(n − 2k) will
be the ”opposite” of it. However, the ”opposite” of the value of k:(n − k)
is the same as the value of k:n. Thus, the value of k:n equals the value of
k:(n − 2k).
As observed above, the values are the same every 2k. Therefore, this implies
that the pattern of the values of positions k:n is periodic with a period of
2k.
The values of k:n for k < n < 2k could be 0, 1 or 2. This is because for this
range of n there are two possible moves to be made, since the difference of
the sizes of the two piles (n − k) is always smaller than the size of the small
pile. Thus, the two moves which are always possible from k:n are to move
the game to positions k:(n − k) and (2k − n):n. Every position of the game
has a value. The fact that the next possible moves are two, means that not
all the three values could be included in the set of values of the next possible
positions and that the smallest value not included will be the value of k:n.
Thus, a position with two possible moves can only have values 0, 1 or 2.
8.3.1. Results.
The program implemented generates the values of each pile size. It can
generate values for very big pile sizes such as 100.000 in seconds. Below, in
table 4 the first 16 values generated by the program can be observed. In
table 5 there is an interesting property that will be discussed and tried to
be proved in the analysis of the game.
15
Pile Size 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Value 0 1 1 1 1 1 1 1 1 1 0 0 2 2 0 0 2
8.3.2. Analysis.
Lemma 8.3. The maximum possible value of a position n is equal to the
number of different non-zero digits of n.
8.4.1. Results.
The program implemented generates values of positions for up to 4 piles and
it can be easily adjusted to generate values for positions with more piles, if
needed. In table 6, one can see the first values generated for positions with
2 piles in the game.
16
Piles k,n 1 2 3 4 5 6 7 8 9 10
1 0 1 1 1 1 1 1 1 1 1
2 0 2 2 2 2 2 2 2 2
3 0 3 3 3 3 3 3 3
4 0 4 4 4 4 4 4
5 0 5 5 5 5 5
6 0 6 6 6 6
7 0 7 7 7
8 0 8 8
9 0 9
10 0
It can be easily observed that the values of 2-pile positions are the same as
the size of the smaller of the two piles of each 2-pile position. From a position
k-n with k < n, exactly k moves can be made. The possible positions after
a move are on the right diagonal of the specific position in table 6. Thus, all
possible next positions include all values up to but not including k, making k
the smallest value not included in the set of the next possible moves’ values
and therefore the actual value of the position.
The next two theorems 8.5 and 8.6 are introduced in this section and will
be described further and proved later in the 3-pile and 4-pile analysis of the
game respectively.
Theorem 8.5. A position of the form x-y-y is a position with value 0.
All the 3-pile positions with at least 2 equal piles have a value of 0. Firstly,
all 3-pile positions with 2 equal piles have a value of 0 because they only
lead to positions with non-zero values such as those of the form k-n and
k-n-`, where k < n < `. Also, 3-pile positions with 3 equal piles have a value
of 0 as they are final positions and no further move can be done from this
point.
Theorem 8.6. A position of the form k-k-n-n is a position with value 0.
All the 4-pile positions with pairs of equal pairs of piles have a value of 0. A
position k-k-n-n, where k 6= n can only lead the game to positions k-n-`-o
with all different piles sizes. These positions only have non-zero values and
as such k-k-n-n will have a value of 0. Positions with 4 equal piles have also
a value of 0 as they are final positions and no further move can be made.
8.4.2. Analysis.
1-pile positions:
In this game, all 1-pile positions are final positions since there is no further
move to be made according to the rules.
17
Analysis for 2 piles:
Proof. In a W -position such as k-n where k > n, a player has always the
choice to move the game to a state where only one pile is left; move all
matches from pile n to the larger pile k. This is a position described in F ,
L.
Therefore, there is always a move to some L-position from any W -position.
The fact that F and L are the exact same sets means that every time the
game ends up to a position in L it automatically finishes.
Therefore, the following theorem follows from Lemma 8.7 together with the
obvious fact that positions in F belong to L:
Theorem 8.8. F , L and W are, respectively, the final, losing and winning
positions of the game.
Proof. In a W -position such as k-n-` where k > n > `, a player has always
the choice to move the game to a state where two piles have the same size;
move to position (k + m)-(n − m)-` where (n − m) = ` by moving m matches
from pile n to larger pile k. Since the piles ` and (n − m) are equal, position
(k + m)-(n − m)-` is in L. The exceptional case where only two equal piles
remain and ` = 0, which is a F -position, is also a L-position as F is a subset
of L.
Therefore, there is always a move to some L-position from any W -position.
18
Lemma 8.10. From any L-position, every move leads to a W -position.
Therefore, the following theorem follows from Lemmas 8.9 and 8.10, together
with the obvious fact that positions in F belong to L:
Theorem 8.11. F , L and W are, respectively, the final, losing and winning
positions of the game.
As the positions included in theorem 8.5 are also included in the 3-pile
L positions proved in theorem 8.11, these positions have a value of 0 and
therefore theorem 8.5 is proved.
Strategy: When in any position in W , the player has to move m matches
from n to k, as described in Lemma 8.9, to lead the game to a position in
L.
Therefore, the following theorem follows from Lemmas 8.12 and 8.13, to-
gether with the obvious fact that positions in F belong to L:
Theorem 8.14. F , L and W are, respectively, the final, losing and winning
positions of the game.
As the positions included in theorem 8.6 are also included in the 4-pile
L positions proved in theorem 8.14, these positions have a value of 0 and
therefore theorem 8.6 is proved.
In addition to the losing positions described above there are some more
0-positions that arise for 4 piles. For example, some of them are positions
such as n-5-3-1 when n > 8 and n-6-3-2 when n > 9. There are also some
0-positions which cannot be described and a more general rule about them
could not be found. Examples of these are positions like 9-8-5-2, 10-9-5-2,
8-6-5-4 and 9-7-6-5.
21
9. Verification and Validation
22
10. Summary and Conclusions
10.1. Summary.
Over the course of this project four different impartial combinatorial games
have been introduced and researched. Software that generates values for all
positions of each game has been implemented. Strict mathematical proofs of
interesting facts/patterns observed from the data generated from the soft-
ware have been written.
10.3. Conclusion.
In conclusion, various impartial combinatorial games have been explored. As
a result, many interesting facts about unknown impartial games have been
identified and proved during the process of this experimental project.
23
References
[1] Archimedes-lab.org (2018). Play nim game online [online] Available at: http:
//www.archimedes-lab.org/game_nim/play_nim_game.html, [Accessed 10
Mar. 2018].
[2] Goobix.com (2018). Nim. [online] Available at: http://www.goobix.com/
games/nim/, [Accessed 10 Mar. 2018].
[3] Cut-the-knot.org. (2018) Bogomolny, A. Grundy’s Game from Interactive
Mathematics Miscellany and Puzzles. [online] Available at: https://www.
cut-the-knot.org/Curriculum/Games/Grundy.shtml, [Accessed 10 Mar.
2018].
[4] Siegel, A. (2013). Combinatorial Game Theory. Trovidence (Rhode Island):
American Mathematical Society.
[5] Nowakowski, R. (1996). Games of no chance. Cambridge: Cambridge University
Press.
[6] Grundy, P. M. (1939). Mathematics and games, Eureka. 2, 6-8; reprint Eureka
27 (1964) , 9-11
[7] Sprague, R. P. (1935–36). Über mathematische Kampfspiele, Tohoku Mathe-
matical Journal 41: 438-444
[8] Sprague-Grundy Values of Grundy’s Game (2002). Grundy’s Game. [on-
line] Available at: http://wwwhomes.uni-bielefeld.de/achim/grundy.
html [Accessed 6 Mar. 2018].
[9] E. Berlekamp, J. H. Conway, R. Guy. (1982). Winning Ways for your Mathe-
matical Plays, 96. Academic Press.
24