-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotsandboxes.tex
1901 lines (1605 loc) · 85.4 KB
/
dotsandboxes.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[a4paper,twocolumn]{article}
\usepackage{palatino}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{color}
\usepackage{calc}
\usepackage{wasysym}
\DeclareMathOperator{\mex}{mex}
\newcommand{\loony}{\rightmoon}
\newcommand{\cgtgame}[2]{\{#1 \:|\: #2\}}
\newtheorem{thm}{Theorem}[section]
\newtheorem{freecoins}[thm]{Theorem}
\newtheorem{loonyoptions}[thm]{Theorem}
\newtheorem{loonynonneg}[thm]{Theorem}
\newtheorem{halfheartedbad}[thm]{Theorem}
\newtheorem{opensmallest}[thm]{Theorem}
\newtheorem{gamelength}[thm]{Theorem}
\newtheorem{dnbgamelength}[thm]{Corollary}
\newtheorem{parityruleofthumb}[thm]{Rule}
\newtheorem{dnbparityruleofthumb}[thm]{Rule}
\begin{document}
\title{The Dots-and-Boxes Game}
\author{Andrew Medworth (\texttt{https://github.com/amdw})}
\date{\today}
\maketitle
\begin{abstract}
An introduction to the game dots-and-boxes, and to the more general
game strings-and-coins. Aims to explain why these games are
interesting, and to discuss some principles of strategy. Intended
for readers with some mathematical background: anyone unfamiliar
with techniques such as proof by induction will probably find this
paper difficult, and may prefer to learn the game from another
source instead.
\end{abstract}
\tableofcontents
\section{Introduction}
\subsection{The rules of dots-and-boxes}
Dots-and-boxes is a game for two players.
\begin{enumerate}
\item The game is played on a rectangular grid of dots, of a size
agreed prior to the game.
\item A move consists of drawing a line of the player's choice
connecting a pair of horizontally or vertically adjacent dots.
\item It is possible for a player's move to complete either one or
two $1 \times 1$ boxes. When this happens, the player scores one
point for each completed box (normally recorded by writing her
initial inside each one) and \emph{must} make another move: a
player's turn comes to an end when she makes a move which does not
complete any boxes (or which ends the game).
\item The game ends when all boxes have been completed; the winner
is the player who has completed more boxes.
\end{enumerate}
An example game on a $2 \times 2$ grid is shown in Figure
\ref{sampledab}; each move played is shown in bold, with the letter
under each position showing the player making that move. (Grid
dimensions are generally quoted in the number of \emph{boxes}.)
\begin{figure*}
\centering
\def\svgscale{0.7}
\input{fig_sampledab.pdf_tex}
\caption{Sample dots-and-boxes game on a $2 \times 2$ grid, which
player $A$ wins 3--1}
\label{sampledab}
\end{figure*}
The rules of dots-and-boxes are very simple: the game can be learned
in moments, and it can be played purely with pencil and paper. The
size of the board can be varied to alter the complexity and length of
the game: games are normally played on grids larger than the one in
the example, at least $5 \times 5$. (An odd number of boxes is often
chosen to prevent ties.)
The strategy of the game is deep and interesting, and the aim of this
paper is to explore it in more detail.
\subsection{Strings-and-coins}
Dots-and-boxes is a special case of a more general game called
\emph{strings-and-coins}.
\begin{enumerate}
\item This game begins with a set of \emph{coins}, and a set of
\emph{strings} each connecting a pair of coins; some coins may
also have one or more strings connecting them to the
\emph{ground}. The exact starting position is agreed before the
game.
\item A move consists of removing a string of the player's choice.
\item It is possible for a player's move to remove the last string
connected to either one or two coins. When this happens, the
player captures those coins, removing them from the game, and
\emph{must} play another move, her turn ending when she removes a
string which does not win any coins (or which ends the game).
\item The game ends when all coins are captured; the winner is the
player who has taken more coins.
\end{enumerate}
Specifically, the $m \times n$ game of dots-and-boxes is the special
case of strings-and-coins where $mn$ coins are connected in a
rectangular $m \times n$ grid, with the outer coins connected to the
ground (the four corner coins having two ground links each, and the
other edge coins having one ground link each). The equivalences
between the two games are as follows:
\begin{itemize}
\item A box in dots-and-boxes is equivalent to a coin in
strings-and-coins (and the completion of a box is equivalent to the
capture of a coin).
\item A place where a line can be drawn in dots-and-boxes is
equivalent to a string in strings-and-coins (vertical lines are
equivalent to horizontal strings and vice versa).
\item Lines at the edge of a dots-and-boxes position are equivalent to
ground strings, and internal lines are equivalent to strings
connecting two coins.
\end{itemize}
The strings-and-coins game parallel to the dots-and-boxes game in
Figure \ref{sampledab} is shown in Figure \ref{samplesnc}. Connections
to the ground are indicated by arrows. In each position, the moves
played are shown in bold. Underneath is the player making the move
shown, along with the score following that move.
\begin{figure*}
\centering
\def\svgscale{0.7}
\input{fig_samplesnc.pdf_tex}
\caption{Sample strings-and-coins game equivalent to Figure \ref{sampledab}}
\label{samplesnc}
\end{figure*}
Strings-and-coins is a more general game than dots-and-boxes, because
in strings-and-coins it is possible to start with a position of any
shape and connectivity whatsoever, whereas in dots-and-boxes, the
``coins'' are fixed in a rectangular grid, and all strings have length
1 and are either vertical or horizontal. For example, in
strings-and-coins it is possible to have a loop of three coins,
whereas this is not possible in dots-and-boxes. This greater
generality means that anything we learn about strings-and-coins will
also apply to dots-and-boxes.
Strings-and-coins is also of interest because it helps to focus the
eye on the important aspects of positions, namely the coins and the
connectivity between them, and to abstract away unimportant details
which do not affect the play, such as the orientation and shape of
chains or loops of coins. In the dots-and-boxes representation, by
contrast, the eye tends to be drawn towards the lines, while the
important things (the boxes and their connectivity) are empty space.
For these reasons, we will mostly focus our attention on
strings-and-coins, occasionally making reference to dots-and-boxes
where something we learn has specific implications there.
\section{Basic definitions}
Where possible, I have tried to be consistent with the standard
terminology of graph theory, and with existing literature such as
\cite{berl}.
We will call the two players $A$ and $B$, with $A$ generally moving
first in a given position.
The \emph{valency} or \emph{degree} of a coin is the number of strings
connected to it (these terms are borrowed from graph theory). In the
starting position of dots-and-boxes, all coins have valency 4; each
move reduces the valency of either one or two coins by 1. A coin of
valency 1 can be immediately captured.
A \emph{joint} is a coin of degree 3 or more.
A \emph{loop} is a connected set of coins which all have valency 2,
and form a circuit. An \emph{$n$-loop} is a loop consisting of $n$
coins. (In dots-and-boxes, there are no loops with fewer than four
coins, and due to the symmetry, all loops have an even number of
coins.)
A \emph{(closed) chain} is a connected set of coins with valency 2
which is not a loop. A chain has two ends, which can either be
connected to the ground or to a joint. An \emph{open chain} is one
which can be immediately captured, i.e.\ a chain where one or both
ends has valency 1; in the special case where both ends have valency
1, we may refer to it as an \emph{opened loop}. A \emph{$n$-chain} is
a chain consisting of $n$ coins.
A chain is \emph{independent} if it is connected to the ground (rather
than a joint) at both ends.
The act of \emph{opening} a chain or loop is cutting it so that it
becomes an open chain, which can then be captured.
A \emph{double-cross move} (or \emph{double-crossed move}) is a move
which wins two coins at once (because the string removed connected two
coins of valency 1). These moves are of strategic importance for
reasons we will see later.
Let $V(P)$ be the net value of a position $P$ from the perspective of
the player to move, assuming optimal play from both sides, and
independent of how $P$ was reached (i.e.\ the value of the remaining
coins, ignoring any coins taken earlier in the game). Clearly $V(P)$
will be an integer, and could be either positive, zero or negative,
according to whether $P$ is favourable or unfavourable for the player
to move. $V(P)$ is also known as the \emph{minimax} value of $P$ and
$V$ is the \emph{value function} of strings-and-coins.
The value function can be computed recursively: any terminal position
has value zero, and the value of a non-terminal position is the
maximum across all legal moves of any coins captured by the move plus
the value of the resulting position (from the perspective of the
correct player).
\section{Endgame fundamentals}\label{endgamesection}
To understand the strategy of a game, it is often a good idea to begin
with positions close to the end of the game, since the understanding
of earlier positions depends on later ones.
\subsection{Control and double-dealing moves}
Let us consider a very simple endgame position $S_n$ consisting of a
single closed $n$-chain. Obviously $V(S_n)=-n$, as there is no
alternative but to open the chain for the opponent, who will take all
$n$ coins straight away.
Now consider the position $D_n$ with $2n$ coins divided into
\emph{two} closed $n$-chains. At first glance it might appear that
this position is a $n$--$n$ draw, as $A$ must open one chain for $B$,
who will take it and then be forced to open the other one for
$A$. However this is not true: when $A$ opens the first chain, $B$ can
take all but the last two boxes, and then sacrifice them with a
\emph{double-dealing move} as shown in Figure \ref{dddemo} (with
$n=5$). Because this move does not win a coin, it ends $B$'s turn, and
forces $A$ to make a move. $A$ might as well take the two sacrificed
coins, because in either case, he is also forced to open the remaining
chain for $B$, which $B$ then wins. Thus $B$ wins by $2n - 2$ points
to $2$, so $V(D_n) = 4-2n$.
\begin{figure}
\centering
\def\svgscale{0.7}
\input{fig_doubledeal.pdf_tex}
\caption{Maintaining control through double-dealing}
\label{dddemo}
\end{figure}
Notice that this only works with $n \ge 3$: a closed chain of length 2
can be opened by removing the middle string, in which case a
double-dealing move is impossible. Only when $n \ge 3$ is there no way
to open a closed $n$-chain without allowing a double-dealing move.
A similar situation arises with loops, but with one important
difference: when a loop is opened, in order to play a double-dealing
move a player must sacrifice four boxes, rather than two, as shown in
Figure \ref{loopdoubledeal}. This is because an opened loop has no
link to the ground, so the only way to avoid taking a coin at the end
(and thus be forced to continue making moves) is to take the string
between two connected pairs of coins, sacrificing both pairs. This
means that a double-dealing move is only possible with an $n$-loop if
$n \ge 4$.
\begin{figure}
\centering
\def\svgscale{0.7}
\input{fig_loopdoubledeal.pdf_tex}
\caption{Double-dealing on a loop}
\label{loopdoubledeal}
\end{figure}
Double-dealing moves are an absolutely central concept in
strings-and-coins strategy, because they allow a player to maintain
\emph{control} of a position, to decide whether to play first in the
rest of the position or to force the opponent to do so.
Because of this, a \emph{long chain} is defined as a chain of at least
\emph{three} coins, and a \emph{long loop} is defined as a loop of at
least \emph{four} coins. A long chain or loop is one which cannot be
opened without allowing a double-dealing move. By contrast a
\emph{short} chain or loop is one which is not long.
(I do not particularly like this terminology, because the words
``long'' and ``short'' are such common words, and giving them a
specific technical meaning like this can often be confusing. However
they are standard in the dots-and-boxes literature, so throughout this
paper I have tried to consistently use ``long'' and ``short'' in this
technical sense, preferring ``large'' and ``small'' in more informal
contexts.)
If there are more than two $n$-chains, notice that player $B$ can
maintain control all the way to the end of the game, by taking all but
two coins of each chain and then playing a double-dealing move,
forcing $A$ to open the next chain at the cost of two coins, and
repeating this for each chain except the last, which he can capture in
its entirety. This strategy will certainly win the game if $n>3$; if
$n=3$ then the situation is slightly more complex, because sacrificing
two coins from a 3-chain results in a net loss of one coin. A similar
observation holds true for loops which are sufficiently large to allow
a double-dealing move without net loss. We will explore this topic in
more detail in section \ref{smallchains}.
\subsection{Loony moves and positions}
A \emph{loony move} is defined as a move which allows the opponent to
play a double-dealing move. There are four types of loony move:
\begin{enumerate}
\item Opening a long chain
\item Opening a long loop
\item Opening a 2-chain by cutting the link at one of the ends:
this is called a \emph{half-hearted handout}, in contrast to a
\emph{hard-hearted handout} which is opening the 2-chain by
cutting the middle link (and is not a loony move).
\item Handing one of these situations back to the opponent by
playing in an unrelated area of the board when the opponent has
made a loony move of their own.
\end{enumerate}
A \emph{loony endgame} is defined as a strings-and-coins position in
which the only possible moves are loony moves. A \emph{loony position}
is defined as one in which a double-dealing move is
possible.\footnote{In practice, loony positions come about only when a
loony move has just been made. The only other possibility is if the
starting position is loony, which makes little sense.}
These concepts are extremely important to the theory of
strings-and-coins. The basic reason for this is that in a loony
position, the player has a free choice between taking all the coins on
offer and then playing first in the rest of the position, or playing a
double-dealing move, forcing the opponent to play first in the rest of
the position at the cost of either two or four coins (depending
whether a chain or a loop is involved). This is a powerful option,
which will generally lead to victory if exercised correctly (we will
discuss the exceptions in section \ref{smallchains}).
We will now examine some properties of loony positions, starting with
our first theorem.
\begin{loonyoptions}\label{loonyoptions}
Let:
\begin{itemize}
\item $L$ be a loony position
\item $m$ the number of capturable coins in $L$
\item $P$ the same position with all $m$ capturable coins removed,
and
\item $s$ the minimum number of coins which must be sacrificed in
order to play a double-dealing move in $L$ ($s$ will be $2$ or
$4$ according to whether $L$ contains an open long chain, or
only opened long loops).
\end{itemize}
Then the optimal strategy from $L$ is either to take all $m$ coins
on offer and then make the optimal move in $P$, or to take all but
$s$ coins and play a double-dealing move, and thus
$$V(L) = \max(m+V(P), m-2s-V(P))$$
\end{loonyoptions}
\begin{proof}
Taking all $m$ coins and playing optimally in $P$ results in a gain
of $m+V(P)$ coins, and taking all but $s$ coins and double-dealing
results in a gain of $m-2s-V(P)$ coins (assuming best play from both
sides thereafter). So we immediately have $$V(L) \ge \max(m+V(P),
m-2s-V(P))$$ and it remains only to show equality by demonstrating
that no other possible strategy can yield a better outcome than both
of these options.
Any strategies from $L$ other than these two must fall into one of
two categories:
\begin{itemize}
\item Making a move in the $P$ part of the position while there
are $n > 0$ capturable coins still available
\item Making a double-dealing move while there are still $n > s$
capturable coins available
\end{itemize}
In the first case, the gain from this strategy can be no greater
than $m-n+V(P)$, as the opponent can take all the capturable coins
the first player eschewed and play from there (and there may even be
better options available). At best, the first player has achieved
nothing over the take-all-$m$ strategy other than to give the
opponent $n$ free coins. $m-n+V(P) < m+V(P)$ and so this strategy
cannot be optimal.
In the second case, the gain can be no greater than $m-2n-V(P)$, as
the opponent can take all $n$ remaining capturable coins and play in
$P$ (and may again have even better options). At best, the first
player has achieved nothing over the take-all-but-$s$ strategy other
than to give the opponent $n - s$ free coins. $m-2n-V(P) <
m-2s-V(P)$ so this strategy can be discarded as well.
Therefore, the optimal strategy from $L$ must be one of the two
given.
\end{proof}
This argument relies on the fact that $P$ plays out the same way
regardless of which player goes first in it. Whatever strategy one
player uses from $P$ can also be used by the other if the first player
makes a different decision from $L$, thus reversing their roles. This
type of reasoning is known as a \emph{strategy-stealing} argument.
The power of the choice offered by a loony position is now clear. If
$V(P)$ is positive, we can take all the capturable coins and proceed
to reap that gain; on the other hand, if $V(P)$ is negative, we can
make the double-dealing move and force that loss on our opponent.
\begin{loonynonneg}\label{loonynonneg}
If a player has just made a loony move, her opponent can always
score at least half of the remaining points: in other words, for any
loony position $L$, $V(L) \ge 0$.
\end{loonynonneg}
\begin{proof}
Let $P$, $m$ and $s$ be defined as in Theorem
\ref{loonyoptions}. From that theorem we already know that $$V(L) =
\max(m+V(P), m-2s-V(P))$$
If $V(P) \ge -m$ then $m+V(P) \ge 0$ and $V(L) \ge 0$ straight away,
so suppose $V(P) < -m$. Then $m-V(P) > 2m$, and thus as $m \ge
s$, $$m-2s-V(P) > 2m-2s \ge 0$$ so in this case $V(L) \ge 0$ also.
\end{proof}
Notice that this is a non-constructive proof, which does not tell us
which of the two options (taking all the coins or making a
double-dealing move) is the correct one. The position $P$ might be
very complex, and it could be difficult to work out whether it is more
favourable to play first or second in it. The strategy-stealing
argument simply shows that since the first player has a free choice
between these two options, and one of them must avoid a net loss of
coins, a loony position cannot be unfavourable for the first player.
This shows that it is \emph{generally} undesirable to make a loony
move; that is not always the case, though, as sometimes the
alternatives are actually worse. We will see some examples in section
\ref{smallchains}.
However the third and fourth types of loony move can never be the sole
optimal move, and we will prove that now.
\subsection{Canonical play results}
\begin{freecoins}\label{freecoins}
Any coins which can be captured without affecting the ability to
play a double-dealing move later in the turn should always be
captured immediately.
\end{freecoins}
\begin{proof}
If the position is loony, this result is exactly the same as Theorem
\ref{loonyoptions}, so it remains only to check the case where the
position is not loony (i.e.\ there are capturable coins but no
double-dealing move is possible).
However this case is very simple, as we will be forced to play in
the rest of the position regardless of whether we capture the
available coins or not. If we do not, our opponent can capture the
coins herself and continue as if we had done so, so we have achieved
nothing except to hand some free coins to our opponent.
\end{proof}
\begin{halfheartedbad}\label{halfheartedbad}
A half-hearted handout is never better than a hard-hearted handout.
\end{halfheartedbad}
\begin{proof}
Let $P$ be the position without the two coins concerned.
The value of the position after the hard-hearted handout is
$2+V(P)$, as the two coins should always be captured by Theorem
\ref{freecoins}.
A half-hearted handout by $A$ gives $B$ the choice whether to take
the two coins and play first in $P$, or to play a double-dealing
move, which sacrifices two coins but forces $A$ to play first in
$P$. So the value of the position after the half-hearted handout
is $$\max(2+V(P),-2-V(P)) \ge 2+V(P)$$ by definition of $\max$.
\end{proof}
Results like this, which prove that a certain type of move can never
be worse than another type, are known as \emph{canonical play}
results. These are extremely useful, because they can significantly
simplify the calculations necessary to evaluate a position.
For example, Theorem \ref{halfheartedbad} means we never have to
consider half-hearted handouts, because we know they will never be
better than the equivalent hard-hearted handout. If the choice is
between a hard-hearted and a half-hearted handout, we can say the
former is the \emph{canonical move}.
Theorem \ref{freecoins} is even more powerful: it means that in many
situations where there are capturable coins, we do not need to
consider the possibility of not taking them. When a long chain or loop
is opened, taking all but the last few coins (two for a chain, four
for a loop) is \emph{canonical}, so we need only consider two
possibilities: taking the whole chain and the double-dealing move.
(It is important to realise that canonical play results only prove
that certain types of move cannot be the sole best move in the
position, and hence cannot affect the \emph{optimal} value of the
position. They say nothing about whether the position is winning or
losing. In some losing positions, a non-canonical move can give the
opponent more opportunities to go wrong, and so might be worth a try
in a practical game.)
Here is another useful canonical play result.
\begin{opensmallest}\label{opensmallest}
For any two independent chains, or any two independent loops, of
different sizes, it is never better to open the larger one than the
smaller one.
\end{opensmallest}
\begin{proof}
The proof uses a useful technique mentioned in \cite{berl} called
\emph{the man in the middle}. This is a form of proof by
contradiction.
Suppose someone claims that, contrary to this theorem, they have
found a position where opening the larger structure is better than
opening the smaller one. We challenge this person to two
simultaneous games, both starting from that position. In Game 1,
player $A$ is required to start by opening the smaller structure; in
Game 2, player $A$ must start by opening the larger one. We take the
role of player $A$ in Game 1, and our imaginary antagonist does the
same in Game 2: she gets the position she prefers to play as $A$,
and so do we.
In order to prove she is right, our opponent will have to get a
better result as player $A$ in Game 2 than we can achieve as player
$A$ in Game 1: if she cannot, then her claim fails and the theorem
is proven.
The ``man in the middle'' technique shows that our challenger's task
is indeed impossible, by taking the moves she plays in one game and
playing equivalent moves against her in the other game, according to
an equivalence we specify. The proof works by showing that
regardless of the strategy our opponent chooses, we can
\emph{always} find such equivalent moves, and that they will
\emph{always} result in us doing at least as well in Game 1 as she
does in Game 2. Our antagonist is essentially playing against
herself, and we are the ``man in the middle'', hence the name.
In this case, we see how our opponent responds to our opening of the
smaller structure in Game 1, before choosing how to respond to her
opening of the larger one in Game 2:
\begin{itemize}
\item If she takes the whole structure, we take the whole larger
structure in Game 2, leaving us ahead.
\item If she plays a double-dealing move, we play a double-dealing
move ourselves on the opened structure in Game 2 (which we can
always do, because the structure opened in Game 2 is larger). This
again leaves us ahead, because the structures are either both
chains or both loops, so the number of coins which must be
sacrificed to double-deal is the same, and our structure is
larger.
\item If she opens the larger structure, we open the smaller
structure in Game 2.
\item If she plays elsewhere in the position, we copy her move in
the other game.
\end{itemize}
We then await our opponent's response in Game 2, and make the
equivalent move in Game 1, according to the same scheme: any move
our opponent makes on the smaller structure in Game 2 we replicate
on the larger structure in Game 1, and if she moves in the rest of
the position, we simply copy her. We repeat this strategy until the
both games are over.
If $P$ is the position minus the two structures concerned, we will
always achieve exactly the same score in $P$ in Game 1 as our
opponent achieves in $P$ in Game 2, so any difference in outcomes
will boil down to the two structures themselves.
We may end up winning the larger structure in Game 1 or we may not;
if we do, then we do better in Game 1 than our opponent in Game 2,
because we win the larger structure and lose the smaller one in Game
1, whereas our opponent wins the smaller one and loses the larger
one in Game 2. (If our win of the larger structure is minus some
coins sacrificed by a double-dealing move, so will be our opponent's
win of the smaller structure in the other game.)
However, even if we lose the larger structure in Game 1, we will win
the smaller structure in Game 2, meaning both players win both
structures in their respective games (possibly minus the same number
of sacrificed coins), leaving the final outcomes the same.
This shows that regardless of how good a strategy our opponent
chooses in Game 2, we can always do \emph{at least} as well in Game
1, possibly better. For any strategy which starts with the opening
of the larger structure, we can specify a strategy starting with the
opening of the smaller structure which is at least as
good. Therefore, it \emph{cannot} be better to open the larger
structure than the smaller one.
(This proof depends on the fact that the two structures are
independent of $P$, so no move played on them can affect our ability
to copy our opponent in $P$. It also depends on the fact that any
move played on a smaller structure can be copied on the larger one
with no net loss of coins.)
\end{proof}
\subsection{Structure sizes and control}
\label{smallchains}
From the preceding discussion, it is clear that the concept of control
is extremely important to understanding a strings-and-coins
position. However, the winner in strings-and-coins is the player who
wins most coins, not the player who makes the last move or controls
the flow of the play. We now explore the relationship between these
two concepts.
First, suppose we have a position composed of an arbitrary
sub-position $S$ and a single chain with more coins than in all of
$S$. In this case, since the big chain contains more than half the
coins, the game will be won by whichever player can win it: neither
player will open the big chain unless they have no choice, so both
players will strive \emph{not} to take the last coin in $S$. In this
case control of $S$ will determine the outcome of the game.
In general, the more a position is dominated by chains and loops with
a large number of coins, the more important it is to have control,
because this will determine who is forced to give them away.
The complication comes from the fact that when a small enough chain
and or loop is opened, keeping control requires a net sacrifice of
coins, so if the position is dominated by such structures, naively
keeping control all the way to the end can result in defeat. It is in
these contexts that giving away control with a loony move can actually
be the optimal approach.
A chain or loop which does not require a net loss of coins to make a
double-dealing move is defined as \emph{very-long}. Because making a
double-dealing move in a chain requires a sacrifice of two coins and
in a loop requires four coins, we now have the following
classification:
\begin{itemize}
\item Chains of length 1 and 2 and loops of length 1, 2 or 3 are
short (as they can always be opened with a non-loony move)
\item Chains of length 3 and loops of length 4, 5, 6 or 7 are long
but not very-long (as they can only be opened with a loony move,
but keeping control with a double-dealing move requires a net loss
of coins)
\item Larger chains and loops are both long and very-long (these can
only be opened with a loony move, after which control can be kept
with no net loss).
\end{itemize}
(Again I register my objection to this terminology, but it is standard
and I will stick to it.)
We will now examine how smaller chains and loops affect
strings-and-coins positions.
\subsubsection{Long but not very-long chains and loops}
Here we examine the effect of small long chains and loops by
considering a family of loony endgame positions $P_{i,k}$ consisting
of $i$ 3-chains and one $k$-chain, with $k \ge 3$. For example,
$P_{4,5}$ is shown in Figure \ref{p45}.
\begin{figure}
\centering
\def\svgscale{0.7}
\input{fig_p45.pdf_tex}
\caption{Position $P_{4,5}$}
\label{p45}
\end{figure}
In $P_{i,k}$, $A$ can choose whether to open the $k$-chain or one of
the 3-chains, and in response, $B$ can choose whether to take the
whole chain or take all but two boxes and play a double-dealing move.
By Theorem \ref{opensmallest}, $A$ never does better to open the
$k$-chain than one of the 3-chains, so to compute $V(P_{i,k})$, we
need only consider opening a 3-chain, followed by either taking or
double-dealing in reply by $B$. Since removing one of the 3-chains
from $P_{i,k}$ yields $P_{i-1,k}$, we can calculate $V(P_{i,k})$
recursively as follows.
\begin{eqnarray*}
V(P_{0,k}) & = & -k \\
V(P_{i+1,k}) & = & \min(-3-V(P_{i,k}), 1+V(P_{i,k}))
\end{eqnarray*}
Example calculations for $k=3$, $k=4$ and $k=10$ can be seen in tables
\ref{vpik3}, \ref{vpik4} and \ref{vpik10}.
\begin{table*}[p]
\centering
\begin{tabular}{c c c c c c}
$i$ & $V$ if $B$ takes & $V$ if $B$ double-deals & $V(P_{i,3})$ & $B$ taking optimal? & $B$ double-dealing optimal? \\
\hline
$0$ & $-3$ & $1$ & $-3$ & Yes & No \\
$1$ & $0$ & $-2$ & $-2$ & No & Yes \\
$2$ & $-1$ & $-1$ & $-1$ & Yes & Yes \\
$3$ & $-2$ & $0$ & $-2$ & Yes & No \\
$4$ & $-1$ & $-1$ & $-1$ & Yes & Yes \\
$5$ & $-2$ & $0$ & $-2$ & Yes & No \\
$6$ & $-1$ & $-1$ & $-1$ & Yes & Yes
\end{tabular}
\caption{$k=3$}
\label{vpik3}
\end{table*}
\begin{table*}[p]
\centering
\begin{tabular}{c c c c c c}
$i$ & $V$ if $B$ takes & $V$ if $B$ double-deals & $V(P_{i,4})$ & $B$ taking optimal? & $B$ double-dealing optimal? \\
\hline
$0$ & $-4$ & $0$ & $-4$ & Yes & No \\
$1$ & $1$ & $-3$ & $-3$ & No & Yes \\
$2$ & $0$ & $-2$ & $-2$ & No & Yes \\
$3$ & $-1$ & $-1$ & $-1$ & Yes & Yes \\
$4$ & $-2$ & $0$ & $-2$ & Yes & No \\
$5$ & $-1$ & $-1$ & $-1$ & Yes & Yes \\
$6$ & $-2$ & $0$ & $-2$ & Yes & No \\
$7$ & $-1$ & $-1$ & $-1$ & Yes & Yes \\
$8$ & $-2$ & $0$ & $-2$ & Yes & No
\end{tabular}
\caption{$k=4$}
\label{vpik4}
\end{table*}
\begin{table*}[p]
\centering
\begin{tabular}{c c c c c c}
$i$ & $V$ if $B$ takes & $V$ if $B$ double-deals & $V(P_{i,10})$ & $B$ taking optimal? & $B$ double-dealing optimal? \\
\hline
$0$ & $-10$ & $-6$ & $-10$ & Yes & No \\
$1$ & $7$ & $-9$ & $-9$ & No & Yes \\
$2$ & $6$ & $-8$ & $-8$ & No & Yes \\
$3$ & $5$ & $-7$ & $-7$ & No & Yes \\
$4$ & $4$ & $-6$ & $-6$ & No & Yes \\
$5$ & $3$ & $-5$ & $-5$ & No & Yes \\
$6$ & $2$ & $-4$ & $-4$ & No & Yes \\
$7$ & $1$ & $-3$ & $-3$ & No & Yes \\
$8$ & $0$ & $-2$ & $-2$ & No & Yes \\
$9$ & $-1$ & $-1$ & $-1$ & Yes & Yes \\
$10$ & $-2$ & $0$ & $-2$ & Yes & No \\
$11$ & $-1$ & $-1$ & $-1$ & Yes & Yes \\
$12$ & $-2$ & $0$ & $-2$ & Yes & No
\end{tabular}
\caption{$k=10$}
\label{vpik10}
\end{table*}
We know from theorem \ref{loonynonneg} that no loony endgame can have
a positive value, but all the $V(P_{i,k})$ are strictly less than
zero. This is because the 3-chains have an odd number of coins, but
the number of coins you have to sacrifice to make a double-dealing
move is even, so the two never cancel out exactly.
(It is possible to construct a loony endgame position with value 0:
for example, the position consisting of two 4-loops shown in Figure
\ref{drawnloony}. In this case, taking the first loop would mean
sacrificing the second, while double-dealing the first loop would
sacrifice four coins to gain the second loop, with a draw in either
case.)
\begin{figure}
\centering
\def\svgscale{0.7}
\input{fig_drawnloony.pdf_tex}
\caption{A drawn loony endgame position}
\label{drawnloony}
\end{figure}
Notice that the larger the value of $k$ (i.e.\ the bigger the big
chain), the longer double-dealing remains the optimal strategy for
$B$, the player in control. This is to be expected, as the bigger the
chain is, the more points it is worth sacrificing by double-dealing
from 3-chains to capture it.
However, in all cases, once $i$ is large enough (i.e.\ there are enough
3-chains), double-dealing after the opening of the first 3-chain
ceases to become the sole optimal strategy, and if there are an even
number of 3-chains, it ceases to become the optimal strategy at all.
The position consisting of four 3-chains, $P_{3,3}$, is a simple
counter-example to the notion that loony moves are always inferior to
non-loony moves. When $A$ opens the first 3-chain in this position,
$B$ does best to take it, winning 3 coins, and open the next 3-chain
for $A$, even though the latter is a loony move and a non-loony move
could have been played instead.
The reason is that giving away control by playing a loony move in the
position with three 3-chains, $P_{2,3}$, only loses one point, which
is more than offset by the three coins won in the process of reaching
that position. If instead $B$ had played a double-dealing move, he
would have been one point behind from the first chain, and only won
one point from $P_{2,3}$, so the game would have finished drawn.
$P_{3,3}$ is also a counter-example to the idea that the winner of a
strings-and-coins game is always the player who makes the last
move. If $A$ opens the first chain, $B$ takes it and opens the next
chain as discussed above, and $A$ double-deals (which is equally bad
for him as taking), $B$ will be leading 5--1 after the first two
chains are gone. As $B$ will have to open one of the last two chains
for $A$, $A$ will double-deal and then take the last chain, thus
winning the last two chains 4--2 and making the last move, but this
will result in a final score of 7--5 in $B$'s favour. So $A$ controls
whether he will make the last move of the game, by deciding whether to
take or double-deal on the second chain, but he is not able to win.
The same holds true for $P_{i,3}$ for all odd $i \ge 3$.
A very similar analysis would apply if the 3-chains from this example
were replaced by loops of length 4, 5, 6 or 7. All these structures
require a sacrifice of coins in order to retain control, so a precise
analysis of the rest of the position is required in order to know
whether double-dealing or taking is the right strategy. If the rest of
the position is close in score, it may be better to take all the coins
on offer and play a loony move, even though there was a non-loony move
available.
\subsubsection{Short chains and loops}
Recall that the defining characteristic of a short chain or loop is
that it can be opened with a non-loony move; therefore, sacrificing it
does not necessarily entail giving up control of the position.
From Theorems \ref{halfheartedbad} and \ref{opensmallest}, we know
that if we add a single short chain or loop of size $c$ to a loony
endgame $P$ resulting in a position $P'$, the best move will be to
open that short chain or loop (with a hard-hearted handout, if
applicable), sacrificing all the coins in it, but forcing our opponent
to play first in $P$, and thus $V(P') = -c-V(P)$.
If we continue to add short chains or loops to the position, the sign
of its value will flip back and forth, as the players will alternately
open one of the short structures, until one of them is forced to play
a loony move.
To see how this works with a concrete example, consider a family of
positions $S_{i,k}$ consisting of $i$ 2-chains plus one
$k$-chain. Then:
\begin{equation*}
V(S_{i,k}) =
\begin{cases}
-k & \text{if } i = 0,\\
-2-V(S_{i-1,k}) & \text{if } i > 0
\end{cases}
\end{equation*}
For the case $k=3$, this means the value of the position alternates
between $-3$ (for even $i$) and $+1$ (for odd $i$), as either player
$A$ loses two coins on the last 2-chain but wins the final 3-chain, or
makes an even score on the 2-chains but has to give away the 3-chain.
For larger $k$, the oscillations as $i$ is increased are even larger,
as the significance of who wins the $k$-chain becomes greater. For
example $V(S_{i,10})$ is $-10$ for even $i$ and $+8$ for odd $i$.
\subsection{Summary}
The concepts in this section are absolutely central to dots-and-boxes
strategy.
\emph{Double-dealing moves} sacrifice a small number of coins (two on
a chain, four on a loop) to force the opponent to play first in the
rest of the position.
If a double-dealing move is available, it is also possible to capture
all available coins and play first in the rest of the position
yourself. The ability to choose freely between these two options is
very powerful, allowing the player to capture at least half the
remaining coins in the position if exercised correctly.
A \emph{loony position} is one where a double-dealing move is
possible, and a \emph{loony move} is a move resulting in a loony
position. Many of the more advanced aspects of dots-and-boxes strategy
revolve around trying to avoid making a loony move, or forcing the
opponent to do so. The only way a player can win the game after making
a loony move is if he already has a large enough lead to outweigh the
coins his opponent can win from the resulting loony position.
A \emph{long} chain or loop is one which can only be opened by a loony
move. A \emph{very-long} chain or loop is one with enough coins that
when it is opened, a double-dealing move can be played without net
loss.
In a non-loony position, any available coins can always be captured
immediately, without further analysis. In a loony position, any
available coins other than the two or four required to play a
double-dealing move can similarly always be captured.
A \emph{half-hearted handout}, being a type of loony move, is never
better than the corresponding (non-loony) \emph{hard-hearted handout},
and opening a longer independent chain or loop is never better than
opening a shorter one.
Once a loony move has been made, the correct strategy is to maintain
control (by avoiding loony moves of your own) to the end of the game,
provided there is enough potential profit in very-long chains and
loops to outweigh any coins sacrificed, which is normally the case in
practice.
If there are not enough coins in very-long structures to outweigh
sacrifices for control, the analysis is more complex, sometimes
requiring loony moves.
\section{Middlegame fundamentals}
Having established some basic principles of endgame play, we now
consider how to aim towards a winning endgame while still in the
middlegame.
We have seen that provided there are enough long chains and loops in
a position, the winner will be the player who establishes control by
forcing his opponent to play a loony move. This suggests the following
general procedure for winning a game of strings-and-coins:
\begin{enumerate}
\item Ensure there are enough long chains and loops in the position
\item Force your opponent to make a loony move
\item Win the endgame using the techniques we have already seen
\end{enumerate}
This is how most games are won in practice. In this section we will focus
on the second element: how do we ensure that our opponent will run out of
non-loony moves before we do?
\subsection{How long is a game?}
When we succeed in playing according to the above procedure, we will
generally play the last move of the game, having forced our opponent to
open the last chain or loop for us. (The only exception will be if the
position is dominated by not-very-long structures, as we saw in section
\ref{smallchains}.)
It is therefore important to consider whether there are any general
guidelines we can use to determine which player will make the last
move in a game, as that player will generally be able to win.
In this section, we will prove some results about how many turns there
are in a game of strings-and-coins or dots-and-boxes. Obviously, if
the total number of turns in the game is odd, the player who moves
first in the game will play last, whereas if this number is even, her
opponent will.
It turns out that the number of turns is affected by the number of
double-crossed moves made during the course of the game, in a way
which is perhaps slightly surprising. The following theorem shows
exactly how\footnote{I have never seen this theorem stated in quite
this way in the dots-and-boxes literature, but I would be surprised
if it is a new result, as it is merely a generalization to
strings-and-coins of a well-known result for dots-and-boxes.}.
\begin{gamelength}\label{gamelength}
For any game of strings-and-coins starting from a position with $C$
coins and $S$ strings, if $D$ double-crossed moves occur during
the course of the game, then the total number of turns in the game
is $$1 + S - C + D$$
\end{gamelength}
\begin{proof}
Consider a game starting from a position with $C$ coins and $S$
strings. As the game progresses, let $s$, $c$, $d$ and $t$ track,
respectively, the number of strings removed, coins captured,
double-crossed moves made and turns completed.
At the beginning of the game, clearly $$s = c = d = t = 0$$
Since a move is by definition the removal of one string, each move
increases $s$ by $1$, and may increase $c$, $d$ and/or $t$,
depending whether it captures coins or ends a turn.
Any move which does not end the game must be one of the following
types:
\begin{itemize}
\item A move which captures no coins. This ends a turn, so $t$
increases by $1$ and $c$ and $d$ are unchanged.
\item A move which captures one coin. This increases $c$ by $1$,
but does not end a turn, so $d$ and $t$ are unchanged.
\item A double-crossed move. This increases $c$ by $2$ and $d$ by
$1$, but does not end a turn, so $t$ is unchanged.
\end{itemize}
Each of these leaves the quantity $s - c + d - t$ unchanged, and
since this quantity is zero at the start of the game, we have $$t =
s - c + d$$ at every move of the game, up to the last move.
The final move of the game must either be a single-coin capture or a
double-crossed move, capturing the last one or two coins. Such moves
leave the quantity $s - c + d$ unchanged. The only difference
between the final move and any other capture is that it completes a
turn (and thus increases $t$ by $1$).
Thus, at the end of the game, $$s - c + d - t = -1$$ and at this
point obviously $s = S$, $c = C$, and also $d = D$, the number of
double-crossed moves in the whole game. Hence at the end of the