Go diagrams with TEX

Hanna Kołodziejska1
MacroSoft, Ltd.
ul. Chrościckiego 49
02-414 Warsaw, Poland

Encoureged by Zalman Rubinstein, who described his chess diagrams in TUGboat vol. 10 no. 2 [1], I have prepared some special fonts and TEX macros to be used in typesetting go diagrams. For all the people who have never yet played go I found the following introduction to the game [2]:

Go is one of the most ancient, interesting, and rewarding of all board games. [...] It is played on a wooden board marked with nineteen vertical and nineteen horizontal lines. The pieces used are disks of slate and white shell slightly more than two centimeters in diameter. These, even made of plastic or glass, as in mass-produced sets, are called stones. They are played on the intersections formed by the lines on the board, not within the squares. The board is empty at the beginning of the game, and the two players take turns placing stones on it one at a time, one player playing black the other playing white. Once played, a stone remains in its place, not moving about from point to point.

Go diagrams are easy to read. 1 is the first stone played, 2 the second, and so on.

In order to facilitate inserting go diagrams in a text both in Plain TEX and LATEX, I decided to generate with Metafont all the symbols needed, even lines and circles, and to put them in three kinds of fonts:

  1. fonts with black stones, eg. go1bla10, go2bla10 (go black stones at 10pt);
  2. fonts with white stones, eg. go1whi10, go2whi10 (go white stones at 10pt);
  3. fonts with additional symbols, like intersections of lines, border lines, etc., eg. go10 (go symbols at 10pt).
Probably two more fonts will be needed with black and white stones numbered over 255, because games which last over 300 moves are not seldom!

The macros for coding go diagrams are gathered in the `go.sty' file. In the macros each line intersection is identified by the row label (one of the letters: a, b, c, d, e, f, g, h, i, k, l, m, n, o, p, q, r, s, t) and the column number (from 1 to 19). After issuing the command:

\input go.sty
the current go diagram is initialized (with no stones on it). Later in your text you can clear the whole diagram or only a part of it by introducing one of the commands:
\inifulldiagram
or
\inidiagram with parameters.
For example, \inifulldiagram is equivalent to:
\inidiagram a-t:1-19
(with a space limiting the fourth parameter).

The same rule stands also for showing diagrams:

\showfulldiagram
is equivalent to:
\showdiagram a-t:1-19
Partial diagrams are often used to show go problems, their solutions and different variations of moves.

Putting a stone on the board is coded by the command:

\pos with parameters.

Lets consider an example: a problem to solve (Dia. 1) and its solution (Dia. 2).

20 a5=. a6=. b3=. b4=. b5=. b6=. c3=. c4=. c5=. d3=. e2=. e3=. e4=. e6=&utri#triangle;

\begin{figure}\begin{displaymath}
\showdiagram a-g:1-9
\end{displaymath}\begin{center}Dia. 1 \end{center}\end{figure}


\input go.sty          %  inputs macros
\gofontsize{20}        %  chooses the size of stones and other
                       %  symbols (default=10pt)
\pos{a}{5}=\white.     %  puts a white stone (without any number)
\pos{a}{6}=\black.     %  puts a black stone (without any number)
                       %  on the a6 intersection
\pos{b}{3}=\white.
\pos{b}{4}=\white.
\pos{b}{5}=\white.
\pos{b}{6}=\black.
\pos{c}{3}=\white.
\pos{c}{4}=\black.
\pos{c}{5}=\black.
\pos{d}{3}=\white.
\pos{e}{2}=\black.
\pos{e}{3}=\black.
\pos{e}{4}=\black.
\pos{e}{6}=\black{\triangle}  %  puts a black stone with
                              %  a triangle
$$                     %  centering
\showdiagram a-g:1-9   %  the result is shown in Dia. 1
$$
\pos{b}{1}=\black{1}   %  puts a black stone with 1
\pos{c}{2}=\letter{b}  %  puts a letter `b' on
                       %  the c2 intersection
\pos{d}{2}=\letter{a}
\gofontsize{10}        %  changes the size of stones and
                       %  other symbols
$$
\showfulldiagram       %  as in Dia. 2.
$$
\inifulldiagram        %  clears a board

b1=1 c2=b d2=a 10

\begin{figure}\begin{displaymath}
\showfulldiagram
\end{displaymath}\begin{center}Dia. 2 \end{center}\end{figure}

An example of a real game is shown in Dia. 3 [3].

a1=194 a3=191 a5=187 a6=186 a8=181 a9=190 a12=175 b1=135 b2=184 b3=182 b4=183 b5=193 b6=178 b8=179 b9=172 b10=174 b12=93 b13=92 b14=142 c1=132 c2=133 c3=196 c4=3 c5=189 c6=176 c7=17 c8=173 c9=171 c10=168 c11=195 c12=57 c13=141 c14=10 c15=52 d1=134 d2=137 d3=13 d4=188 d5=15 d6=177 d7=180 d8=21 d9=170 d10=169 d11=9 d13=154 d14=143 d15=51 d16=2 d17=54 d18=24 e1=140 e2=136 e4=12 e7=14 e8=192 e9=20 e13=160 e16=53 f2=62 f3=64 f4=58 f6=16 f7=70 f8=166 f10=158 f11=50 f13=144 f17=23 g1=84 g2=63 g3=60 g4=19 g5=59 g6=65 g7=66 g8=69 g9=148 g10=157 g11=76 g14=81 g15=87 g18=139 h2=82 h3=61 h7=67 h8=68 h9=22 h10=147 h11=75 h12=77 h14=79 h15=80 h17=123 h18=138 i1=94 i2=83 i4=5 i6=18 i7=71 i15=74 i17=55 i18=120 k2=95 k7=73 k8=86 k9=72 k10=165 k11=11 k17=119 k18=118 l4=49 l6=89 l7=88 l8=127 l9=128 l10=115 l13=116 l15=78 l16=121 l17=56 l18=117 m6=91 m7=90 m8=129 m9=114 m10=125 m12=145 m16=124 m17=122 n7=113 n9=159 n10=167 n11=164 o2=131 o4=7 o9=153 o12=156 o16=28 p1=130 p2=111 p6=85 p8=152 p9=151 p11=162 p12=155 p13=104 p14=108 p15=26 p16=25 p17=106 p18=34 q2=110 q3=45 q4=1 q7=103 q8=150 q9=149 q10=8 q11=161 q12=100 q13=101 q14=107 q15=30 q16=29 q17=36 r1=112 r2=47 r3=42 r4=43 r6=6 r7=99 r8=146 r9=97 r11=40 r12=39 r15=31 r16=4 r17=27 r18=96 s2=46 s3=48 s4=44 s7=102 s8=126 s9=185 s11=98 s12=41 s13=109 s15=35 s16=32 s17=33 t16=37

\begin{figure}\gofontsize{15}
\begin{displaymath}
\showfulldiagram
\end{displaymath}\begin{center}Dia. 3 \end{center}\end{figure}

Diagrams are put in a text like ordinary vboxes.

The stones can be also put directly in a paragraph. To do this you should use the \textwhite and \textblack commands instead of \white and \black. For example, the sentence from the beginning of this article: ``1 is the first stone played, 2 the second, and so on'' was written as: ``\textblack{1} is the first stone played, \textwhite{2} the second, and so on.''

There are no other secrets in coding go diagrams. Macros for making 9×9 or 13×13 diagrams can easily be added to `go.sty' by a simple modification of the existing macros for 19×19 diagrams.