BEHIND GO ENDGAMES

QINGYUN WU ADVISOR: PROF. FLORIAN BLOCK

Abstract. In this thesis we will take a look at the connection between com- binatorial game theory and Go endgames. Although prior knowledge of Go and combinatorial game theory can be helpful, they are not required for this thesis. Chapter 1 and 2 are overviews of Go and combinatorial game theory re- spectively, and chapter 3 provides basic examples. Chapter 4 and 5 discuss an advanced topic called temperature theory and its application to Go endgames. Chapter 4 focuses on the theory while chapter 5 demonstrates practice. Over- all, the purpose of this thesis is to up a rigorous mathematical foundation for analyzing Go endgames.

Contents 1. Overview of Go 1 1.1. Introduction 1 1.2. Rules of Mathematical Go 3 2. Basics of Combinatorial Game Theory 4 2.1. What Are Combinatorial Games? 4 2.2. Game Sums and Comparisons 6 2.3. , Fractions and Infinitesimals 7 2.4. Canonical Forms 9 3. Basic Applications of Combinatorial Game Theory in Go 11 3.1. Formulation and Basic Positions 11 3.2. General Positions 12 3.3. What We Can Do Now And A result For A Certain of Games 14 4. Temperature Theory and Its Application to Go 15 4.1. Avoidance Theorem and Switching Games 15 4.2. Cooling and Temperature 16 4.3. Warming - The Weapon For Go Endgames 17 5. Time to Make Some Plays 18 5.1. Chilled Go Games 18 5.2. In A Real Battle 20 References 21

1. Overview of Go

1.1. Introduction. Go is a 2-player board game originated from ancient China around 4000 years ago. In modern days, Go is very popular in China, Japan and Korea. It is considered as 1 2 QINGYUN WU an official sport in these areas; some international tournament like Ing Cup awards $400k to the champion. The game is played alternatively by two players, we call them Black and White, on the grids of a 19 × 19 board (sometimes 13 × 13 or 9 × 9). In each move, each player put a stone of his color on a empty grid of the board in order to enclose the most ”territory”. The concept of ”territory” seems vague, indeed different rules have different interpretations. In Chinese rule, both your (alive) stones on the board and the grids enclosed by them are counted as ”territory”, while in Japanese rules, only the grids enclosed by stones are counted. In most of the cases, these two rules yield the same result. For the purpose of applying mathematics to Go, we will need to combine and modify some commonly used rules. Before we go into further discussion of our rules, we should define when a stone or a group of stones are alive. Figure 1 below is the last game of a best of 3 final in the 2012 Samsung Cup, played by Lee Sedol and Gu Li. We will use it to illustrate some concepts. (Picture credit to Tom Weiqi)

Figure 1. Lee Sedol vs Gu Li in the final of 2012 Samsung Insur- ance World Masters Baduk

For each piece of stone on the board, the grids directly next to it (up, down, left, right), that are not occupied by other stones, are called liberties of that stone. For example, the black stone 263, at the position J-18, has 3 liberties, namely J-17, J-19, I-18. Several stones of the same color are considered as a connected group if they occupy connected grids along horizontal or vertical lines, and they share the liberties. For instance, the group of black stones 55, 45,43, 139, 201, 53, 5 around D-16 on the left bottom corner are considered as a group and they have 2 MATHEMATICS BEHIND GO ENDGAMES 3 liberties in total (E-13, E-14). A group of stones is alive if it has at least one liberty and is ”captured” (or ”killed”) if it has no liberty left and will be removed from the board. A move that makes a group of stones has no liberty (called suicidal move) is not allowed in any Go rule, unless this move immediately captures some enemy stone(s) and therefore leaves the group at least one liberty after removing the enemy stones. In figure 1, White moves in G-5 is considered as a suicidal move and therefore is not allowed. Also we should notice that for black stone 263 at position J-18, although it has 3 liberties for now, it is considered as ”dead”, since if both players keep playing the game (people usually just stop here) ratio- nally, it will eventually run out of liberties and get captured. However, the group of black stones 55, 45,43, 139, 201, 53, 5 around D-16 mentioned above is alive, since unless White makes two moves in a row, these 7 stones can safely connect to the large group to their right. Of course, now a good question is whether the large group can eventually be captured just like black 263, or is it guaranteed to be alive? Experienced Go players will say it is always alive, since it has at least two separate ”eyes”. An ”eye” is just a territory that is completely surrounded by stones of one color and the boundaries of the board. For example, G-5, J-7 are eyes for Black. Also, R-18 and R-19 as a whole forms a single black eye. In most of the situations, a group of stones is considered as alive if and only if it can be made into two eyes assuming both players play optimally. In this thesis, we will not bother much about the life and death situation; in all the examples discussed below, we consider all the pieces as alive, unless they are obviously captured like black 263.

Now we can look at the conventional score systems of Go. We will introduce the Japanese style of scoring: the score of Black (White) = the number of grids enclosed by black (white) stones + the number of white (black) stones captured by Black (White). The player with higher score wins. We do not really care about komi (the compensation points for the advantage of moving first, usually Black gives to White, since conventionally Black moves first). In the game shown in fig- ure 1, Black wins half a point after a 6.5 point komi, which means Black has 7 more points on board and captures. As you may see this score system does not perfectly fit the definition of combinatorial game, but it is very close in the sense that the score you get is essentially how many more moves you can make.

In the next section, we will discuss some modifications we made on the conven- tional Go rules for the purpose of applying combinatorial game theory.

1.2. Rules of Mathematical Go.

The rules in this sections are based on the discussion in Elwyn Berlekamp’s paper ”Introductory overview of mathematical Go endgames”[3], with some modification to fit the purpose of this thesis. In previous section we already discussed basic concepts of Go. Now we will dis- cuss some additional rules and a way of determining outcome class that will agree with the usual scoring system and suit the definition of combinatorial game: 4 QINGYUN WU

Rule 1: Returning a captured stone to the opponont is considered as a legal move in addition to playing on the board.

Rule 2: No passing is allowed.

Rule 3: (The outcome class) The player who can not make a legal move in his turn loses the game.

The result obtained by this rule will agree with the result under Japanese rule, the only difference is that if both players have the same point in Japanese rule, then instead of being a draw, the second player is considered as the winner.

Rule 4: No loopy positions on the board. This basically means there is no ”ko” in the sense of Go play. We also assume there is no ”seki”, which is the situation when two groups of opposite color rely on shared liberty to stay alive.

”Ko” and ”seki” are very important concepts in Go and show up a lot in actual Go play. But a lot of combinatorial game theory only apply to finite games. So for simplicity, we will not discuss them in this thesis. It does not matter if you do not know what they are, we will not address them in the rest of the thesis. If you are interested, the Go page in Wikipedia explains them very well.

Rule 5: All the stones on the board are assumed to be alive unless they are obviously captured. We will not worry about life and death situation. In actual Go games, this always happens when enough moves are made.

2. Basics of Combinatorial Game Theory

2.1. What Are Combinatorial Games?

A combinatorial game is played between two players, usually called Left and Right. These two players take turns to move, changing current game position into a position in his own option set. The options for each player are well-defined by certain rules of the game. In the process of playing, both players have perfect information and there is no randomness involved in the moves. The outcome of the game depends on who makes the last move: the game is called normal if the player who made the last move wins, and mis`ere if the player who made the last move loses. In our thesis, we will only discuss combinatorial games under normal play. In general, combinatorial games can be divided into two different classes: a game is called impartial if both players have the same options, and partisan if they have different option sets. Generally speaking impartial games are easier to solve and Sprague-Grundy Theorem takes care all of them in theory (any impartial game is equivalent to one pile of , and the size of the pile can be computed by Sprague-Grundy function recursively, please refer to section 1.1.3 of [9] for more MATHEMATICS BEHIND GO ENDGAMES 5 information). We will focus on partisan games in this thesis. Also, we will only consider finite games, i.e., the game is guaranteed to end in finitely many steps. Famous examples of combinatorial games are Nim, Domineering, Dots-and- Boxes, Hex etc. The definition of these games can be found in Wikipedia easily. Now we will introduce the formal definition of combinatorial game: Definition 2.1. A game G is called a combinatorial game if all the left options and right options of G are combinatorial games, where left (right) options are the positions that Left (Right) player can move G into. Symbolically, we write L L R R L R G = {G1 ,G2 , ...|G1 ,G2 , ...}, where Gi and Gi are left and right options of G. L R L L L For simplicity, we usually write G = {G |G }, where G = {G1 ,G2 , ...} and R R R G = {G1 ,G2 , ...}. Under this notation G is a combinatorial game if and only if all the GL and GR are combinatorial games. This is a recursive definition, with the base case to be the empty game, which is just the game that both players have no move. We can also define the outcome classes of a game: Definition 2.2. Given a game G, we say G belongs to outcome class (assuming both players play optimally) N (Next/first player wins) if the player who moves first always wins the game; P (Previous/second player wins) if the player who moves first always loses the game; L (Left player wins) if Left always wins the game no matter who moves first; R (Right player wins) if Right always wins the game no matter who moves first.

With this definition we have a very important theorem: Theorem 2.3. Every combinatorial game belongs to exactly one of the outcome classes defined in definition 2.2. We prove this theorem using the following lemma (based on the discussion in chapter 2 of [6]): Lemma 2.4. For a combinatorial game, played by A and B, either A is guaranteed to win moving first, or B is guaranteed to win moving second. As always, we assume both players play optimally. Proof of lemma 2.4: we use induction on the depth of game tree. Base case: lemma is clearly true for the empty game. Now, for any combinatorial game, look at the positions that A can move into. By induction, these positions are either B wins moving first, or A wins moving second. If all the moves of A lead to positions that B is guaranteed to win moving first, then in the original game, B is guaranteed to win moving second; otherwise, A can choose to move to the position where he is guaranteed to win moving second, and therefore wins the original game, i.e., A wins the original game moving first. 

Back to the theorem, it follows fairly straightly from the lemma:

Proof of theorem 2.3: We have two players, Left and Right, by lemma, exactly one of (1) Left wins moving first and (2) Right wins moving second is true. Also, exactly one of (3) Left wins moving second and (4) Right wins moving first is true. 6 QINGYUN WU

So: if we have (1), (3), the game has outcome class L; if we have (1), (4), the game has outcome class N; if we have (2), (3), the game has outcome class P; if we have (2), (4), the game has outcome class R. 

Remark 2.5. From the proof we can see theorem 2.3 is true for any combinatorial game, under normal play or mis`ereplay, impartial or partisan!

2.2. Game Sums and Comparisons.

This section follows the guideline in section 4.1 of ”Lessons in Play” [6].

We would like to define the notion of the sum of games. Intuitively we want the sum of two games G and H to be a game where in each move, a player can choose to play in G or H, following the rules in the corresponding game. For example the sum of a chess game and a Go game will have two boards (one chess board, one Go board) side by side, and in each move, a player can choose to play in either the chess board or Go board. One important thing is that we do not allow the two games to intervene with each other, just like a move in the chess game will not affect the position of the Go game. With this in mind, we can make a formal recursive definition for game sums. Definition 2.6. The sum of two games G and H, denoted by G + H, is equal to {GL + H,G + HL|GR + H,G + HR}. We can also define the negative of a game, intuitively we are just switching the role of Left and Right. Definition 2.7. The negative of G is defined as −G = {−GR| − GL}. The negative of the empty game is just itself. Now we can define subtractions: Definition 2.8. Subtraction: G − H is defined as G + (−H). The addition of games is associative and commutative, in fact it has many nice properties just like the usual addition of numbers. We will see that in the rest of this section. But before we look into the algebraic structure of the games, we should first define the notion of ”equal”. You may want to define two games to be equal if they are identical as sets, but in many situations, we do not need/want to make the definition so strict. In fact, we only need G and H to behave similarly in the sense of addition. Definition 2.9. We say two games G and H are equivalent (write G = H), if for any game X, G + X and H + X have the same outcome class. It is easy to verify that this defines an equivalence relation. One important consequence of this definition is that all the games with outcome class P are equiv- alent. Furthermore they are equivalent to the game where both players have no legal move, which is usually called the 0 game. This equivalence class will serve the purpose as the additive identity of combinatorial games. More precisely: MATHEMATICS BEHIND GO ENDGAMES 7

Theorem 2.10. A combinatorial game G is equivalent to 0 if and only if G has outcome class P, where 0 is defined as {∅|∅}, which is usually written as {|}. The proof of this theorem can be found in section 4.1 of ”Lessons in Play” [6].

With all these definition, we have many basics properties just like in the usual number system. We will list some of them here without proofs. They can be verified easily by the arguments used in a first course of abstract algebra. You can refer to section 4.1 of [6] for detailed proofs. Properties 2.11. (1) (G + H) + K = G + (H + K) (2) G + H = H + G (3) G + 0 = 0 + G = G (4) −(−G) = G (5) G + (−G) = 0 (6) If G = G0, H = H0, then G + H = G0 + H0 (7) G + K = H + K if and only if G = H

We also would like to compare two games. Conventionally, we say G ≥ H if G is a better position for Left than H. It can be precisely defined as below: Definition 2.12. Comparison Define G ≥ H if for any game X, Left wins G + X whenever Left wins H + X. Define G ≤ H if for any game X, Right wins G + X whenever Right wins H + X. Define G > H if G ≥ H and G 6= H. Define G < H if G ≤ H and G 6= H. It should be no surprise that G ≥ H if and only if H ≤ G, and ”≥” and ”≤” are two partial orderings on combinatorial games. Again we will list some important properties with regard to the ordering. Some of them are very handy for comparing games in practice. Proofs can be found in section 4.1 of [6]. Properties 2.13. (1) G ≥ H if and only if G − H ≥ 0; (2) G ≥ 0 if and only if Left wins moving second; (3) G + K ≥ H + K if and only if G ≥ H. Remark 2.14. Similar results are true for ”≤”. In practice, if we want to compare two games G and H, we just look at the outcome of G − H: if G − H ∈ L, then G > H; if G − H ∈ R, then G < H; if G − H ∈ P, then G = H; if G − H ∈ N, then we say G and H are incomparable, or G is fussy with H, usually denoted as GkH.

2.3. Numbers, Fractions and Infinitesimals.

In the previous section we already defined the 0 position, which is the additive identity. A natural question is: are there other numbers in games? Maybe we 8 QINGYUN WU can define positive ? Maybe even fractions? What about ordinal num- bers? These questions are answered by John Conway in his book ”On Numbers and Games” [7] in 1976. In that book, he introduced the idea of ”” and its connection with combinatorial games. In this thesis, we do not need to understand the whole system of surreal numbers, instead we will focus on some dyadic number and some very commonly seen infinitesimals in combinatorial game theory.

First we look at integers. As in the previous section, we know a game is positive if it is a Left player wins situation, and negative if it is a Right player wins situation. So how should we define numbers like 1? The intuition is that we want 1 to be the game that left has a move to the 0 position, where Right has no legal moves. In this way, the game is a Left player always wins case, and Left wins the game by one more move. Definition 2.15. We define 1 to be {0|}, and recursively define n + 1 to be {n|}. Also for any negative n, we just define n to be the negative of −n. For example, −1 = {|0}. Remark 2.16. Easy to see in this definition, a positive integer n is a game that Left has n more ”free moves” than Right, and a negative integer −m is a game where Right has m more ”free moves” than Left. Now that we have all the integers, we can look at fractions. The simplest fraction 1 1 is probably 2 , we can start with it. By 2 , we are trying to express the solution of 1 x + x = 1. So if we find a game G such that G + G = 1, then we can define G as 2 . 1 Definition 2.17. We define 2 to be the game {0|1}. It is not hard to check 1 {0|1} + {0|1} = 1 (i.e. {0|1} + {0|1} − 1 is a P position). Similarly, 4 is defined as 1 {0| 2 } and so on. 1 Remark 2.18. Defining 2 to be {1|0} is also a reasonable choice; it is a solution of 1 equation G + G = 1. However, if we define 2 this way we will lose a very important property called ”Number Avoidance Theorem”, which is the foundation of many 1 currently developed theories. Therefore we define 2 as the way we did in definition 2.17. We will come back to ”Number Avoidance Theorem” in section 4.1 of this thesis. 1 1 1 i After we define 2 , 4 , 8 , ..., we defined all the games of the form 2j , where i is 1 1 1 odd, and i, j are integers, since it can be expressed as a sum of some of 2 , 4 , 8 , i i−1 i+1 ... More precisely, it is not hard to show that 2j = { 2j | 2j }. You may already see how to define an arbitrary , the trick is to convert it into binary, 1 1 1 possibly infinite, and then express it as a series consisting of 2 , 4 , 8 , .... In this thesis, we restrict our discussion to rational numbers. Here is a rule/theorem that can be used to simplify numbers: (For more discussion of numbers, including the proof of the following theorem, see ”On Numbers and Games” [7] and ”Winning Ways of Your Mathematical Plays” [1]) Theorem 2.19. A game of the form {a|b} is a number if and only if both a, b i are numbers and a < b. In fact, {a|b} = 2j , where j is the smallest non-negative i integer such that there exits some integer i, so that a < 2j < b. If there are multiple i such i’s, then i is the integer such that 2j has the smallest absolute value. MATHEMATICS BEHIND GO ENDGAMES 9

Examples 2.20. With theorem 2.19, we can compute: {2|4} = 3; {−3|5} = 0; 1 3 2 π 1 {−1| − 2 } = − 4 ; { 7 | 4 } = 2 ; {7.2|4.3} is not a number. For the last part of this section, we will introduce some infinitesimals. Definition 2.21. A game G is called an infinitesimal if G 6= 0 and for any positive number x, we have −x < G < x. Below are the three most used infinitesimals in combinatorial game theory: Definition 2.22. Define:

∗ = {0|0} ↑= {0|∗} ↓= − ↑= {∗|0} We will give a list of useful properties that we are not going to prove here (see section 5.2 of [6] for detailed proofs). We will use some of them in later discussions: Properties 2.23. (1) ∗k0 ( is fussy with/incomparable with 0) (2) ∗ + ∗ = 0 (i.e. −∗ = ∗) (3) ↑> 0 and ↓< 0 (4) ↑ k∗ and ↓ k∗ (5) ↓ + ↓< ∗ <↑ + ↑ (∗ is incomparable with ↑ but comparable with ↑ + ↑) (6) ↑ + ↑ +∗ > 0, ↓ + ↓ +∗ < 0 (combine (2) and (5)) The last thing worth to mention is that by definition, the sum of finitely many infinitesimals is also an infinitesimal!

2.4. Canonical Forms.

Given a combinatorial game, can we simplify it? In other words, how can we pick a ”simplest” representative for each equivalent class? The answer is again given by John Conway in [7], he suggested two possible operations to reduce a game into its ”canonical form”. Definition 2.24. (Deleting Dominated Options): If a game G has two left options A and B, say G = {A, B, C, ...|GR} and A ≥ B, then G can be simplified into H = {A, C, ...|GR} by simply deleting option B. We also say option B is dominated by option A for Left. Similarly if G = {GL|A, B, C, ...}, and A ≤ B, then option B is dominated by option A for Right. Intuitively, A is a better option for Left than B, therefore Left should never use option B if he can use option A. Lemma 2.25. In the notation of definition 2.24, we have G = H. In other words, deleting dominated options will not affect the equivalence class of the game. Proof: Assume we deleted a left option B, we need to show G = H, which is equivalent to show G−H = {A, B, C, ...|GR}−{A, C, ...|GR} is P position. By def- inition, {A, B, C, ...|GR} − {A, C, ...|GR} = {A, B, C, ...|GR} + {−GR| − A, −C, ...}. 10 QINGYUN WU

Our strategy is using symmetry:

If Right player moves first, he can choose to either move the game to (1) GR + {−GR| − A, −C, ...}, (here by GR we mean any chosen right option, rather than the whole set of right options, this is a standard abuse of notion) then Left can move the game to GR − GR = 0, which guarantees Left to win this game (Left player is moving second now); or (2) {A, B, C, ...|GR} − A (same argument for C or any other options), then Left can move the game to A − A = 0. Again this will make Left player win the game. Therefore no matter what, Right loses the game moving first. On the other hand, if Left player moves first, the only different situation he can make is B +{−GR|−A, −C, ...}, but then Right can move the game into B −A ≤ 0, which guarantees the Right player to win the game. Therefore when Left player moves first, he will also lose the game. Therefore G − H = {A, B, C, ...|GR} + {−GR| − A, −C, ...} is a P position, which means G = H. 

Definition 2.26. (Replacing Reversible Options): If a game G = {A, B, C, ...|GR} and A has a right option AR = {D, E, F, ...|G, H, I, ...}, if we have AR ≤ G, then we say option A is a reversible option for Left, and G can be simplified into H = {D, E, F, ..., B, C, ...|GR}, by replacing option A with the left options of AR. Similarly can define the Right version of reversible options. Intuitively, if Left choose to move to A, then Right can choose to move the game into AR, which is better than the original G for Right. Therefore Left should not make such a move, unless he would like to move in one of the Left options of AR.

Lemma 2.27. Replacing reversible options will not affect the equivalence class of the game. The proof of this lemma is similar to the proof of lemma 2.25, we will skip it here.

So given a game G, by repeating deleting dominated options and replacing re- versible options, we will eventually get a game G0 that can not be simplified by these two methods any more. All our games are finite, so the process has to stop. We say the game G0 is the canonical form of G, and G0 is canonical. It follows from lemma 2.25 and 2.27 that G = G0. Furthermore, canonical form is unique: Theorem 2.28. If G and H are both canonical, and G = H, then G and H are identical. Here we define identical as: for every option of G, there is a corresponding equal option in H. We follow the proof in the book ”Winning Ways” [1], in the Extras of Chapter 3:

Proof: Notice G − H = {GL|GR} + {−HR| − HL} is a second player win. Now assume Left moves first, and Left’s first move is in G. Say Left moves the game to position GL, then Right must be able to win the game by moving the game into position GLR − H ≤ 0 or GL − HR ≤ 0. But GLR − H ≤ 0 is not possible since in this case GL is a reversible option. Therefore for every GL, there is some HL such that GL ≤ HL. Similarly, start with Right moves first in H, we have for any MATHEMATICS BEHIND GO ENDGAMES 11

0 0 0 HL, there is some GL such that GL ≥ HL. Therefore GL ≥ HL ≥ GL. However, there is no dominated options implies that these three are all equal, therefore for any GL, we can find a HL such that GL = HL. Notice switching the role of Left and Right, or G and H does not affect the argument, therefore we have G and H are identical. 

Example 2.29. Let G = {{5| − 3}|0, ↑}. First, as ↑ is dominated by 0 for Right, we can simplify G to {{5| − 3}|0}. Also we have −3 ≤ {{5| − 3}|0}. This can be checked easily if you know ”number translation principle”, which states: if x is a number, then G+x = {GL +x|GR +x}. Therefore {5|−3} is a reversible option, so we can simplify G to {|0} = −1, as −3 = {| − 2}. Notice −1 can not be simplified further, therefore it is the canonical form of G. As you may see in the example, a lot of times comparing AR and G can be very difficult. An effective way to find the canonical form is to use a computer. The software CGSuite [10] offers the function C() to compute the canonical form of a game.

3. Basic Applications of Combinatorial Game Theory in Go

This chapter will demonstrate some applications of combinatorial game theory introduced in the previous chapter. 3.1. Formulation and Basic Positions.

In section 1.2, we already discussed how can we transfer the score system of Go to the ”making the last move” rule of combinatorial game theory. To summarize, if we consider returning a captured stone to your opponent as a legal move, Go can be seen as the game where the player running out moves loses the game. In this way, Go is now formulated as a combinatorial game. To simplify the situation, we exclude all the loopy positions (”ko”) and ”seki” configurations. We also associate Black with Left Player and White with Right Player.

By definition, the 0 positions are positions where both players have no legal moves. This happens when there are no unoccupied grids on the board and no captured stones for each side. And the equivalence class of 0 positions consist of all the second player wins situation. For example, for any game where there are no unoccupied grids on the board and each player has n captured stones of opposite colors, then the game essentially becomes returning the captured stones one at a time. If both players has the same amount of captured stones, then the game is a second player wins.

Now we look at integers. If Black (Left) has a captured white stone, then his only move is to return the white stone to White (Right), leading the game to 0 position, and White has no legal moves. Therefore this game is {0|}, which is by definition 1. Similarly White has 1 captured black stone is considered as postion −1. And recursively, Black (White) has n captured stones can be defined as position n (−n). 12 QINGYUN WU

How can we define integers on the actual Go board then? We want 1 to be a position where Black has 1 move but White has none. The answer will be a simple one point black ”eye” in the picture below. Hopefully you recall what an ”eye” is in the chapter 1; if not, just take the picture as definition. For all examples in this thesis, a position refers to the interior part of the closure only. ,

¢¡¡¡¡ ¢ ¡ ¢ ¡ ¡ ¢ ¡¡ ¨¥¥¥¥ A one point black eye

For the sake of discussion, we define a coordinate system for our Go board. The grid in the left bottom (intersection of the two bold lines) is defined as the origin, and the horizontal line passing it to the right is defined as x-axis and the vertical line passing it to the top is defined as y-axis.

In this position, Black can fill in the grid (3,3) he enclosed to get to 0 position, and White has no legal moves, since (3,3) is a suicidal move for him. Therefore it is also a 1 position. Starting from this we can get all the integers not exceeding the size of the board. For example, one black eye like this together with one captured white stone is a 2 position (1 + 1). And five such white eyes put together are considered as −5. It is easy to check that the position of a two point black eye in the picture below (the right one) is also a 2 position. ,

¢¡¡¡¡¡¡¡¡ ¢ ¡¡¡¡¡ ¢ ¡ ¡ ¡¡ ¢ ¡ ¡ ¡ ¢ ¡ ¡ ¡ ¡ ¢ ¡¡ ¡ ¨¥¥¥¥¥¥¥¥ Two examples of position 2

So far we have defined integers. In the next section we will talk about more commonly seen Go positions and their corresponding ”value” in combinatorial game theory.

3.2. General Positions.

We shall first look at ∗ = {0|0}. In terms of Go jargon, ∗ is called dame, which is a position looks like the graph below. As we said before, we restrict our attention to the part that is enclosed by already played stones, not the outside areas. In this case, the only possible place to put a stone is (3,3). MATHEMATICS BEHIND GO ENDGAMES 13

¢¡¡¡¡ ¢¡ ¡ ¢ ¡ ¡ ¢¡ ¡¡ ¨¥¥¥¥ ”∗” or ”dame” in Go Clearly both players’ only option will move the game into a 0 position, therefore it is ”∗” by our definition: ¢¡¡¡¡¡¡¡¡ ¢¡ ¡¡ ¡¡ ¢ ¡ ¡ ¢¡ ¡¡¡ ¡¡ ¨¥¥¥¥¥¥¥¥ Left Option and Right Option of ”∗” The game ∗ shows up a lot in real Go endgames. It is also very commonly seen in the game tree of many Go positions. One such example is the ”corridor” position, which is probably the simplest nontrival position in Go. The original study of corridors in mathematical Go was done by David Wolfe in his PhD thesis ”Mathematics of Go : chilling corridors” [8]. ¢¡¡¡¡¡¡¡¡ ¢¡ ¡ ¢¡ ¡¡¡¡ ¡ ¢¡ ¡ ¨¥¥¥¥¥¥¥¥ A ”corridor” {3|{2|{1|∗}}} In this case, Black and White both have many possible moves. For example, One of Black’s options is to put a stone at (6,3), and get 2 points. However, this move is dominated by put a stone at (7,3), which gives Black 3 points. We only consider the optimal moves from each player, and write them done in the game tree. Here, optimal is somewhat vague, it essentially means we will not consider obviously non-optimal or ”suicidal” moves, such as White move in (4,3). In a lot of times we don’t really know if a move is dominated by any other moves, then we just write it down and check it later. The judgement of ”optimal” usually comes out of Go knowledge. With this in mind, there is only one Left (Black) option, which is Black put a stone at (7,3), which is a position 3. The only Right (White) option is also at (7,3), which will leave the game a smaller corridor. So we can continue drawing the game tree, and in the end we will see the game is {3|{2|{1|∗}}}.

Can this game be simplified? The answer is unfortunately no. With the soft- ware CGSuite, we can check {3|{2|{1|∗}}} is already canonical. So some simple Go position like a corridor actually looks complicated in the form of combinatorial game. In fact, a lot of Go endgames will look like this. It becomes very tedious when you are trying to compute game sums of such games. Seems like our new system actually makes the situation more complicated.

The breakthrough of mathematical analysis in Go was the discovery of ”chilling” and ”warming”. They are essentially new efforts to simplify games in Go. The idea is: chilling will make Go positions much simpler, for instance, our corridor will be 1 chilled to 2 8 , then we can do game sums and comparisons for these chilled game. 14 QINGYUN WU

In the end, warming is the inverse of chilling, and through it we can determine the properties of the original game by study the chilled games. Chapter 4 is devoted to introducing these techniques. Before we go into that, we should look at what analysis we can do (at least by theory) with the techniques in chapter 2.

3.3. What We Can Do Now And A result For A Certain Class of Games.

Go is played on a 19 × 19 board, therefore there are so many possible combina- tions of moves that even computers can not keep track all of them. It is clear that we will not be able to do much if we consider the whole Go game as a combinatorial game and try to analyze the game tree for that gigantic game, even if it already reached endgame. Instead, we split the whole Go board into small local positions that are independent of each other. For each such local position, we can draw the game tree, try to simplify it, and then, sum all these simplified positions up. Then simplify this sum further if possible. Hopefully in the end what we get is simple enough for us (or at least for computers) to determine some basic properties like what is the outcome of the game and what is the winning move if there exists one.

The rest of this section will be an example that reflects the idea stated above. Notice it is in no way restricted to Go.

Example 3.1. Assume we have a game sum of some numbers, some ∗’s, some ↑’s and some ↓’s, e.g. G = 2+3×∗+2× ↑ +5× ↓. How can we determine the outcome class of the game and the winning move for the winner? First, we sum up all the numbers, and get a number. We compare this number to 0. Since all other parts are infinitesimals, the comparison of the original game and 0 is dominated by the sum of numbers, given that the sum of numbers is non-zero. More precisely, if the sum of numbers is positive (negative), then the original game is also positive (negative), which means it will be a Left (Right) player wins. The winning move for the winning player is to move in any infinitesimals (in his turn). Moving in numbers might still be a winning move when you have a big lead, but it is better to move in infinitesimals. The justification of this claim is bestly done with Number Avoidance Theorem, which will be introduced in section 4.1. Now, assume the sum of all numbers are 0, then we left a bunch of ∗’s, ↑’s, and ↓’s. Therefore we can write the game sum as a · ∗ + b· ↑ +c· ↓, where a, b, c are nonnegative integers. Furthermore, recall ↓= − ↑, then we can further rewrite the sum to a · ∗ + b· ↑, where a is a nonnegative integer and b is an integer. Also, in properties 2.23, we have ∗ + ∗ = 0, therefore we can restrict a to 0 or 1. Without loss of generality, we can also assume b ≥ 0. If a is 0, then the sum is left as b· ↑. Recall that we have ↑> 0, then the original game > 0 if and only if b > 0 (i.e. Left player always wins). When b > 0, if Right moves first, every move will be a losing move and if Left player moves first, he should pick one of the ↑’s and move it into 0, then he will change the sum of games to 0 if b = 1 or (b − 1) · ∗ if b ≥ 2. No matter what Left can win the new game moving second. When b = 0, then the original game is just 0, which is a second player wins. If a is 1, then we get ∗ + b· ↑. If b = 0, then it is just ∗, first player will win, and his wining move is to move in any ∗ in the original summands, which will take him MATHEMATICS BEHIND GO ENDGAMES 15 to 0 position, guarantees him a win. If b = 1, we get ∗+ ↑ , by (4) of properties 2.23, ∗+ ↑ is fussy with 0, therefore it is a first player wins. Same reason as before,the winning move for Left if he moves first is to move the ∗ to 0 and for Right is to move the ↑ to ∗ therefore leave the game to ∗+∗ = 0, which makes him the winner. Last case is when b ≥ 2, recall from properties 2.23, 2· ↑ +∗ > 0, therefore this case will be a Left player wins, and his winning move when moving first will be moving in any of the ∗ or ↑; and his winning moving when moving second is basically a proof of why 2· ↑ +∗ > 0, which is easy to check! 

So in example 3.1 we solved a class of game positions. Of course we would like to expand this class. In the end of chapter 4, we will introduce ”chilling” and ”warming”, which essentially serve this purpose.

4. Temperature Theory and Its Application to Go

4.1. Number Avoidance Theorem and Switching Games.

When we have a game sum of several games, there are some summands that we are eager to play in, while others we would like to avoid making a move in. The motivation of temperature theory is to measure how badly players would like to move in a given game. We shall start with numbers.

Theorem 4.1. Number Avoidance Theorem: Consider a game G + x, where G is not a number and x is a number, then for both players, making a move in G will yield a result (for him) that is at least as good as making a move in x.

In other words, theorem 4.1 tells us: do not move in a number unless you have to. The proof of this theorem can be found in the Extras of chapter 6 in ”Winning Ways” [1]. The intuition behind it is: if we have a number, which is usually in the form x = {a|b}, where a < x < b, then the Left player will move x to a, which is a worse position for him; same is true for Right, moving x to b is giving advantage to Left. Therefore none of the players would like to make a move in numbers. Because of this, we call the numbers cold games. In fact in section 4.2, we will see the temperature of a number is defined as 0. Now let’s look at some games that both players want to move in:

Example 4.2. A switching game has the form s = {p|q}, where p, q are numbers and p > q. It is easy to show that p > s > q. So if Left makes a move in s, he will move the game to p, which is a better outcome for him than the original game. Furthermore, moving the game to p is much better for Left than letting Right moving the game into q. Similarly, Right has the incentive to move the game to q and denies Left from moving the game to p. For this game, both players want to make a move in it. Also, the larger p − q is, the larger the incentives for both players will be. This concept is captured by the temperature of the game, which we define in the next section. We will compute the temperature of switching games in the next section as an example and we will see that larger p − q corresponds to higher temperature. 16 QINGYUN WU

After the brief introduction of motivations, we can define the concept of temper- ature rigorously.

4.2. Cooling and Temperature.

In order to define temperature, we need to first introduce an operation called cooling:

Definition 4.3. Given a game G, and any nonnegative number t, the game Gt L R is defined recursively by Gt = {Gt − t|Gt + t}, unless there is some nonnegative number r < t such that Gr is infinitesimally close to a number x, in that case we define Gt = x. The new game Gt is called G cooled by t. The intuition is that when we cool a game G by t, we are making both players pay a tax t for each move. Examples 4.4. (1) If G is a number, then Gt = G for any nonnegative number t. (2) If G is an infinitesimal such as ∗, ↑, ↓, Gt = 0 for any nonnegative number t. (3) For a switching game like G = {1| − 1}, we have G0 = G = {1| − 1}, G 1 = 2 1 1 1 1 {1 − 2 | − 1 + 2 } = { 2 | − 2 }, G1 = {1 − 1| − 1 + 1} = {0|0} = ∗, and for all t > 1, Gt = 0 since G1 = ∗ is infinitesimally close to the number 0. (4) A slightly more complicated example (the corridor position in section 3.2): {3|{2|{1|∗}}}1 = {2|{2|{1|∗}}1 + 1} = {2|{1|{1|∗}1 + 1} + 1} = {2|{1|{0| ∗1 +1} + 1 3 5 1}+1} = {2|{1|{0|0+1}+1}+1} = {2|{1| 2 +1}+1} = {2|{1| 2 }+1} = {2| 4 +1} = 9 1 1 {2| 4 } = 2 8 , so after cooling by 1, our corridor becomes a nice number 2 8 . John Conway proved that cooling has the following properties in chapter 9 of his book ”On Numbers and games” [7]. Properties 4.5. (1) (G + H)t = Gt + Ht; (2) G ≥ H ⇒ Gt ≥ Ht, in particular, G = H ⇒ Gt = Ht.

Notice the converse of (2) is not necessarily true. For example, ∗1 and ↑1 are both 0, but they are incomparable.

We need one last lemma before defining temperature.

Lemma 4.6. For any finite game G, Gt is a number when t is large enough. Proof of lemma 4.6: We use induction on the depth of game tree. Say we have a game G = {GL|GR}. Consider all the options of G, by induction they all can be cooled into a number. Pick a t large enough so that all these options are cooled into a number. If Gt is defined by Gr for some Gr infinitesimally close to a number, then Gt is a number by definition. Otherwise, we need to use the recursive definition. By our choice of t, Gt will be in the form {a1, a2, ..., ap|b1, b2, ..., bq}, where a1, a2, ..., ap, b1, b2, ..., bq are all numbers. Deleting all the dominated options, we will get Gt = {a|b}, where a, b are numbers. If a < b, then by theorem 2.19, Gt is already a−b a+b a+b a number. Otherwise, a ≥ b, let k = 2 + 1, then Gt+k = { 2 − 1| 2 + 1} is a number. The induction step is completed.  MATHEMATICS BEHIND GO ENDGAMES 17

Definition 4.7. The temperature of a game G is the smallest nonnegative num- ber t such that for all l > t, Gl is a number. Examples 4.8. (1) If G is a number or an infinitesimal, then G has temperature 0. That is why we call numbers cold and infinitesimals tepid. (2) If G is a switching game defined in example 4.2, say G = {p|q} with p > q, p−q then the temperature of G is 2 . As we expected larger p − q corresponds larger temperature. (3) For more complicated game G, the software CGSuite can compute the temper- ature of G by the command: Temperature(G). As we mentioned in section 4.1, temperature is in general a measure of how eagerly both players want to move in a particular game. Therefore with a game sum of several games, it is usually a good idea to move in the summand with the largest temperature. This is called ”Hot Strategy”. However, this is a heuristic strategy, which means in most cases it will work but in some cases it will not give the optimal move. See the Extras of chapter 6 of [1] for more discussion about heuristic strategies.

4.3. Warming - The Weapon For Go Endgames.

In section 4.2 we saw some examples of how cooling can reduce the complexity of games. However, we still don’t know what information we can get from the cooled games to help analyze the original game. In this section, we will introduce another operation warming, in the effort of inverting ”Cooling by 1”. Much of this section is based on section 3.6 of ”Mathematical Go” [2]. Definition 4.9. Given a game G, the warming operator R is defined by:  Z  G, if G is an even integer G = G + ∗, if G is an odd integer  {1 + R GL| − 1 + R GR}, otherwise We know cooling is a many-to-one process, for example, both ∗ and ↑ become 0 after cooling by 1. So for arbitrary games there will be no inverse operator of cooling. The breakthrough of mathematical analysis of Go endgames is based on a big theorem which claims in a Go endgame, warming is the exact inverse of cooling by 1. Before we look at that, we need two more concepts. Definition 4.10. (1) A Go position is called even (odd) if the number of empty grids enclosed by stones plus the number of captured stones is even (odd). Observe that parity addition for Go positions behaves the same as parity addition for integers, like odd + odd gives even etc. Also, parity alternates during play: making a move in an even position makes it odd; making a move in an odd position makes it even. (2) A Go position is called elementary if there is no ”ko” or ”seki” in the game. Now we can introduce the most important theorem in mathematical Go theory: Theorem 4.11. Let G be an even, elementary Go position in canonical form, then R G = G1. In other words, warming is the exact inverse of cooling by 1. 18 QINGYUN WU

The proof of theorem 4.11 can be found in section 3.6 of [2]. There are 5 lemmas used in order to prove this theorem. Some of the lemmas contain concepts that are not introduced in this thesis, therefore we will not go through the lemmas in detail. Instead, we will focus on the consequences of this theorem. There is one more important definition/jargon that needs to be introduced first:

Definition 4.12. The chilling operator f is defined by:

 n, if G = n or G = n + ∗, for some integer n f(G) = {f(GL) − 1|f(GR) + 1}, otherwise

Comparing this to definition 4.3, chilling is just cooling by 1 without reservation. In fact for Go positions, chilling is exactly the same as cooling by 1, this is a part of the proof of theorem 4.11. R The big picture of the proof is to show: (1) G = f(G) and (2) f(G) = G1, combine (1) and (2) we immediately get theorem 4.11. One thing to point out: both (1) and (2) rely on the fact that all the stopping position of Go endgames are integers. By stopping position we mean the position that all the territories are completely enclosed by stones, which is the time for both player to stop playing. Therefore this result is restricted to Go endgames. R Corollary 4.13. For any elementary Go position G, G1 = G or G + ∗. R Proof: When G is even, G1 = G by theorem 4.11; when G is odd, then G + ∗ R R is even, and G1 = (G + ∗)1 = G + ∗, again by theorem 4.11. 

Example 4.14. Consider the ∗ position in section 3.2, it is an odd position. It is R R R easy to check that ∗1 = 0 and 0 = 0, therefore we indeed have ∗1 = 0 = 0 = ∗ + ∗. Corollary 4.15. There is no elementary Go position equal to a fraction, ↑, ↓, or any other infinitesimal that is not ∗. Proof of corollary 4.15: Just check that when G is a fraction, or any infinitesimal R other than ∗, we have G1 6= G or G + ∗, therefore corollary 4.13 tells us that they can not be elementary Go positions. 

With corollary 4.13 and the linearity of chilling and cooling, if we have a game sum of several Go positions, we can first chill the summands individually, then sum them up, and then warm the sum to determine the outcome of the original game. In this way we greatly expand the configurations that we can analyze. Examples of such kind of analysis will be shown in the next chapter.

5. Time to Make Some Plays

5.1. Chilled Go Games. MATHEMATICS BEHIND GO ENDGAMES 19

If we have a Go endgame, surely we can split the game into several parts, chill each one of them and then carry out analysis in combinatorial game theory. How- ever, what does chilling really mean for Go? The answer is: chilling is just putting a 1-point tax on both players for each move. Therefore given any Go position, computing the chilled value of that position is equivalent to play a Go game where whenever a player makes a move, he will have to give his opponent a stone of his color as a captive or return a captured stone to his opponent, serving the purpose of paying a 1-point tax. We call this modified game chilled Go game. In a chilled go game we also assume that both players stop playing if a position becomes a number; this will agree with definition 4.12. Example 5.1. Let’s look at the ∗ position in the original Go game and evaluate it in the chilled version. Originally both players can move the game into 0, as this game is ∗. In chilled Go game, both players still have only one possible move, which moves the game into 0 position. However, since they have to pay a 1-point tax, this 0 position is actually worth −1 point for Black and 1 point for White, therefore this game is {−1|1}, by theorem 2.19, it is just 0. This agrees with definition 4.12, which defines f(∗) = 0. ¢¡¡¡¡ ¢¡ ¡ ¢ ¡ ¡ ¢¡ ¡¡ ¨¥¥¥¥ ∗ chills into 0 Example 5.2. Corridors are easy to compute in chilled Go games. In example 4.4, 1 we showed that {3|{2|{1|∗}}}1 = 2 8 . This can also be easily verified by playing the chilled Go game and careful tracking the tax. ¢¡¡¡¡¡¡¡¡ ¢¡ ¡ ¢¡ ¡¡¡¡ ¡ ¢¡ ¡ ¨¥¥¥¥¥¥¥¥ 1 {3|{2|{1|∗}}} chills into 2 8 For instance, the following position is a 0 position in chilled Go game as shown in example 5.1. However, White made 3 moves therefore he has to pay 3 points of tax, which means the value of this position is actually 3. In fact, it is easy to check the complete game tree for the chilled Go game is {2|{2|{2|3}}}, which simplifies 1 to 2 8 . ¢¡¡¡¡¡¡¡¡ ¢¡ ¡ ¢¡ ¡ ¡ ¢¡ ¡ ¨¥¥¥¥¥¥¥¥ after white making 3 moves In general, for a corridor position in a chilled Go game with n empty grids, n ≥ 2, 1 it can be similarly computed that the value of the corridor is (n − 2) + 2n−1 , if it is 1 black and −(n−2)− 2n−1 , if it is white. Example 5.2 is the special case when n = 4. 20 QINGYUN WU

There is a summary of chilled Go positions in Appendix E of ”Mathematical Go” [2], which is a useful resource when computing chilled Go position values.

5.2. In A Real Battle.

In the last section, we will illustrate a full analysis on a 9 × 9 board. ¦¤ ¤¤ § ¡ ¡ ¢ ¡¡ ¡¡ ¢ ¡ ¢¡ ¡ £ ¢ ¡

¨¥¥¥¥¥¥  A Real Battle In the Go board above, both Black and White made 26 moves each. So far Black has secured 4 + 2 + 2 = 8 points at the top left, top right and bottom right corners, and White has secured 7 points at the bottom. There are 6 places, namely A,B,C,D,E,F in the picture below, that remain unclaimed. Our goal is to figure out which player can win this game and what his winning move is. ¦¤ A¤ § ¡ ¡ ¢ B¡ C¡ D E ¢¡ ¡ £ ¢ F

¨¥¥¥¥¥¥  6 places to fight over Let’s compute the value of each position in a chilled Go game.

First, E is the 0 position as shown in example 5.1. Second, A,F are corridors, 1 using the conclusion at the end of example 5.2, we know they worth − 2 each. For position B, the only reasonable move for both players is to move at grid B, which gives him 1 point. But he has to pay for the 1-point tax, therefore he essentially moves the game into 0 position, which means in a chilled Go game, position B is {0|0} = ∗. For position C, the chilled game tree will be {2|{2|2}}, which simplifies to 2+ ↑. Similarly one can check position D has value −2+ ↓.

1 Therefore, the total value of the game is: 8 − 7 + (− 2 ) + ∗ + (2+ ↑) + (−2+ ↓ 1 R ) + 0 + (− 2 ) = ∗. We can warm ∗ and get ∗ = {1| − 1}. Also notice the game is at an odd position, then by corollary 4.13, the original Go game before chilling has value {1|−1}+∗. This is clearly a first player wins situation, and the winning move for both players when moving first is to move at position B, by which Left (Right) MATHEMATICS BEHIND GO ENDGAMES 21 moves the game sum to 1 + ∗ (−1 + ∗) and guarantees a win. This concludes our analysis!

References [1] John Conway, Richard Guy and Elwyn Berkelamp: ”Winning Ways for Your Mathematical Plays” (1982). [2] Elwyn Berlekamp and David Wolfe: ”Mathematical Go: Chilling gets the last point”. MA, USA: AK Peters, 1994. [3] Elwyn Berlekamp: ”Introductory overview of mathematical Go endgames”. Combinatorial Games 43 (1991): 73k100. [4] Richard J. Nowakowski: ”Games of no chance”. Vol. 29. Cambridge University Press, 1998. [5] Richard J. Nowakowski: ”More games of no chance”. Vol. 42. Cambridge University Press, 2002. [6] Michael Albert, Richard Nowakowski, and David Wolfe: ”Lessons in play: an introduction to combinatorial game theory.” AMC 10 (2007): 12. [7] John Conway: ”On numbers and games.” (1976). [8] David Wolfe: ”Mathematics of Go : chilling corridors”, PhD thesis, University of California, Berkeley, Nov. 1991. [9] Anna Karlin and Yuval Peres: ”Game Theory, Alive.” [10] CGSuite: http://cgsuite.sourceforge.net/