Debian Codegraph @

texmf-dist/source/latex/hexboard/hexboard.dtx

raw
1 %\iffalse meta-comment
2 %Copyright (c) 2022 Peter Rowlett and Chris Sangwin
3 %
4 %The package is licenced under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/
5 %\fi
6 %\title{\textsf{hexboard} v1.0}
7 %\author{Peter Rowlett and Chris Sangwin}
8 %\maketitle
9 %
10 %\begin{center}
11 % \hexscale{3}
12 % \begin{hexgame}[4]
13 % \hexcellshaded{b}{3}
14 % \hexmove{b}{2}
15 % \hexmove{b}{1}
16 % \hexmove{c}{1}
17 % \hexmove{d}{1}
18 % \hexmove{a}{2}
19 % \hexmove{b}{3}
20 % \hexmove{b}{4}
21 % \hexmove{c}{3}
22 % \hexmove{d}{3}
23 % \hexdot{a}{4}
24 % \hexdot{a}{3}
25 % \hexconnect{b}{3}{a}{3}
26 % \hexconnect{b}{3}{a}{4}
27 % \hexcontent{d}{2}{\(\star\)}
28 % \end{hexgame}
29 % \hexscale{2}
30 %\end{center}
31 %
32 %The package is licenced under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). To view a copy of this license, visit \url{http://creativecommons.org/licenses/by-sa/4.0/}
33 %
34 %\tableofcontents
35 %
36 %\section{Background}
37 %
38 %\verb|hexboards| is a package for \LaTeX\ (that should also work with Lua\LaTeX\ and Xe\TeX) that provides functionality for drawing Hex boards and games. The aim is a clean, clear design with flexibility for drawing different sorts of Hex diagrams.
39 %
40 %\section{Usage notes}
41 %
42 %\subsection{The game Hex}
43 %
44 %In this document it is assumed you know how Hex is played. The players are referred to as A (playing between bottom and top) and B (playing between left and right).
45 %
46 %\subsection{hexpicture}
47 %
48 %Hex boards are drawn inside an environment called \verb|hexpicture|. The basic structure for drawing with this package is
49 %
50 %\begin{verbatim}\begin{hexpicture}
51 %...
52 %\end{hexpicture}\end{verbatim}
53 %
54 %\subsection{Coordinate labels}
55 %
56 %Various commands use coordinates on the hexagonal board as a pair \verb|{x}{y}| using column \verb|x| and row \verb|y|. In this, the column \verb|x| may be specified either as a number or using the column letter. For example, the following two commands are equivalent.
57 %
58 %\begin{verbatim}\hexmove{d}{1}
59 %\hexmove{4}{1}\end{verbatim}
60 %
61 %In this document, letters are used to match the board labels.
62 %
63 %Note that this does not apply to the size of a board, where both dimensions are given as numbers. For example, you ask for a 5 by 7 board, not an e by 7 board.
64 %
65 %\subsection{Order of commands}
66 %
67 %New elements are placed on top of the diagram, so some care should be taken that elements do not obscure each other by placing the command for the bottom element first. This includes counters, shaded cells, dots and lines.
68 %
69 %For example, it is best to draw shaded cells early so that they appear behind other elements. For example, the counter is hidden here:
70 %
71 %\begin{verbatim}\begin{hexpicture}
72 %\hexboard{4}
73 %\hexcounter{b}{2}{B}
74 %\hexcellshaded{b}{2}
75 %\hexcellshaded{c}{3}
76 %\end{hexpicture}\end{verbatim}
77 %
78 %\begin{hexpicture}
79 % \hexboard{4}
80 % \hexcounter{b}{2}{B}
81 % \hexcellshaded{b}{2}
82 % \hexcellshaded{c}{3}
83 %\end{hexpicture}
84 %
85 %Whereas the hidden counter appears if the commands are reordered:
86 %
87 %\begin{verbatim}\begin{hexpicture}
88 %\hexboard{4}
89 %\hexcellshaded{b}{2}
90 %\hexcellshaded{c}{3}
91 %\hexcounter{b}{2}{B}
92 %\end{hexpicture}\end{verbatim}
93 %
94 %\begin{hexpicture}
95 % \hexboard{4}
96 % \hexcellshaded{b}{2}
97 % \hexcellshaded{c}{3}
98 % \hexcounter{b}{2}{B}
99 %\end{hexpicture}
100 %
101 %Indeed, if cells at the edge of the board are to be shaded, do this before drawing the board otherwise the shading will cover the edge border. (On the game board, unshaded cells are transparent.)
102 %
103 %For example, if this happens:
104 %
105 %\begin{verbatim}\begin{hexpicture}
106 %\hexboard{5}
107 %\hexshadedsubrow{b}{e}{1}
108 %\end{hexpicture}\end{verbatim}
109 %
110 %\begin{hexpicture}
111 % \hexboard{5}
112 % \hexshadedsubrow{b}{e}{1}
113 %\end{hexpicture}
114 %
115 %try this instead:
116 %
117 %\begin{verbatim}\begin{hexpicture}
118 %\hexshadedsubrow{b}{e}{1}
119 %\hexboard{5}
120 %\end{hexpicture}\end{verbatim}
121 %
122 %\begin{hexpicture}
123 % \hexshadedsubrow{b}{e}{1}
124 % \hexboard{5}
125 %\end{hexpicture}
126 %
127 %
128 %\section{Basic usage}
129 %
130 %\subsection{Drawing Hex boards}
131 %
132 %The basic usage is via \verb|\hexboard{num}| which draws a Hex board of size \verb|num| by \verb|num|. For example, the command
133 %
134 %\begin{verbatim}\begin{hexpicture}
135 %\hexboard{11}
136 %\end{hexpicture}\end{verbatim}
137 %
138 %Produces a Hex board like this\\
139 %
140 %\begin{hexpicture}
141 % \hexboard{11}
142 %\end{hexpicture}
143 %
144 %\subsection{Drawing Hex games}
145 %
146 %The environments \verb|hexgame| and \verb|hexgamelabels| are used to draw Hex games. These starts a \verb|hexpicture| and also initialise a counter to keep track of moves. The difference is that \verb|hexgamelabels| draws a number on each counter to indicate the order in which pieces were played.
147 %
148 %An optional parameter controls the size of the board, with default 11.
149 %
150 %Within a \verb|hexgame| or \verb|hexgamelabels|, game moves are indicated in the order they are played by \verb|\hexmove{x}{y}|. The colouring of pieces is handled by the counter, so odd-numbered moves are player A and even-numbered moves are player B.
151 %
152 %For example, here is a Hex game on a 4 by 4 board without labelling using \verb|hexgame|:
153 %
154 %\begin{verbatim}\begin{hexgame}[4]
155 %\hexmove{a}{2}
156 %\hexmove{c}{3}
157 %\hexmove{b}{2}
158 %\hexmove{c}{2}
159 %\hexmove{c}{1}
160 %\hexmove{d}{1}
161 %\hexmove{b}{3}
162 %\hexmove{b}{4}
163 %\hexmove{a}{4}
164 %\end{hexgame}\end{verbatim}
165 %
166 %\begin{hexgame}[4]
167 % \hexmove{a}{2}
168 % \hexmove{c}{3}
169 % \hexmove{b}{2}
170 % \hexmove{c}{2}
171 % \hexmove{c}{1}
172 % \hexmove{d}{1}
173 % \hexmove{b}{3}
174 % \hexmove{b}{4}
175 % \hexmove{a}{4}
176 %\end{hexgame}
177 %
178 %Here is a Hex game on a 5 by 5 board with move labelling using \verb|hexgamelabels|:
179 %
180 %\begin{verbatim}\begin{hexgamelabels}[5]
181 %\hexmove{c}{2}
182 %\hexmove{b}{4}
183 %\hexmove{b}{3}
184 %\hexmove{d}{3}
185 %\hexmove{a}{5}
186 %\hexmove{a}{4}
187 %\hexmove{c}{3}
188 %\hexmove{c}{4}
189 %\hexmove{e}{3}
190 %\hexmove{e}{2}
191 %\end{hexgamelabels}\end{verbatim}
192 %
193 %\begin{hexgamelabels}[5]
194 % \hexmove{c}{2}
195 % \hexmove{b}{4}
196 % \hexmove{b}{3}
197 % \hexmove{d}{3}
198 % \hexmove{a}{5}
199 % \hexmove{a}{4}
200 % \hexmove{c}{3}
201 % \hexmove{c}{4}
202 % \hexmove{e}{3}
203 % \hexmove{e}{2}
204 %\end{hexgamelabels}
205 %
206 %By default, player A moves first. A command \verb|\hexskipmove| is used to increment the move counter without placing a piece, which can be used to skip player A's first move if player B is to move first (including, for example, if the swap rule has been used but you wish to maintain labelling that shows the order in which pieces were placed).
207 %
208 %\begin{verbatim}\begin{hexgamelabels}[4]
209 %\hexskipmove
210 %\hexmove{b}{3}
211 %\hexmove{c}{3}
212 %\hexmove{c}{2}
213 %\end{hexgamelabels}\end{verbatim}
214 %
215 %\begin{hexgamelabels}[4]
216 % \hexskipmove
217 % \hexmove{b}{3}
218 % \hexmove{c}{3}
219 % \hexmove{c}{2}
220 %\end{hexgamelabels}
221 %
222 %\subsection{Placing Hex counters}
223 %
224 %Within a \verb|hexpicture|, individual counters can be placed using \verb|\hexcounter{x}{y}{player}|.
225 %
226 %For example,
227 %
228 %\begin{verbatim}\begin{hexpicture}
229 %\hexboard{5}
230 %\hexcounter{b}{1}{B}
231 %\hexcounter{c}{2}{B}
232 %\hexcounter{d}{2}{B}
233 %\hexcounter{c}{1}{A}
234 %\hexcounter{e}{1}{A}
235 %\hexcounter{c}{3}{A}
236 %\end{hexpicture}\end{verbatim}
237 %
238 %\begin{hexpicture}
239 % \hexboard{5}
240 % \hexcounter{b}{1}{B}
241 % \hexcounter{c}{2}{B}
242 % \hexcounter{d}{2}{B}
243 % \hexcounter{c}{1}{A}
244 % \hexcounter{e}{1}{A}
245 % \hexcounter{c}{3}{A}
246 %\end{hexpicture}
247 %
248 %\subsection{Drawing a shaded cell}
249 %
250 %The command \verb|\hexcellshaded{x}{y}| is used to draw a shaded cell.
251 %
252 %For example
253 %
254 %\begin{verbatim}\begin{hexpicture}
255 %\hexboard{4}
256 %\hexcellshaded{b}{2}
257 %\hexcellshaded{c}{3}
258 %\end{hexpicture}\end{verbatim}
259 %
260 %\begin{hexpicture}
261 % \hexboard{4}
262 % \hexcellshaded{b}{2}
263 % \hexcellshaded{c}{3}
264 %\end{hexpicture}
265 %
266 %The default shading colour is yellow. An optional parameter allows you to change this. For example
267 %
268 %\begin{verbatim}\begin{hexpicture}
269 %\hexboard{4}
270 %\hexcellshaded{b}{2}
271 %\hexcellshaded{c}{3}
272 %\hexcellshaded[magenta]{c}{2}
273 %\hexcellshaded[lime]{b}{3}
274 %\end{hexpicture}\end{verbatim}
275 %
276 %\begin{hexpicture}
277 % \hexboard{4}
278 % \hexcellshaded{b}{2}
279 % \hexcellshaded{c}{3}
280 % \hexcellshaded[magenta]{c}{2}
281 % \hexcellshaded[lime]{b}{3}
282 %\end{hexpicture}
283 %
284 %\subsection{Drawing a small dot}
285 %
286 %To indicate a position on the board using a small dot, use \verb|\hexdot{x}{y}|.
287 %
288 %For example
289 %
290 %\begin{verbatim}\begin{hexpicture}
291 %\hexboard{4}
292 %\hexdot{b}{2}
293 %\hexdot{c}{3}
294 %\end{hexpicture}\end{verbatim}
295 %
296 %\begin{hexpicture}
297 % \hexboard{4}
298 % \hexdot{b}{2}
299 % \hexdot{c}{3}
300 %\end{hexpicture}
301 %
302 %\subsection{Drawing lines}
303 %
304 %The command \verb|\hexconnect{x1}{y1}{x2}{y2}| draws a line from cell (\verb|x1|,\verb|y1|) to cell (\verb|x2|,\verb|y2|).
305 %
306 %For example
307 %
308 %\begin{verbatim}\begin{hexpicture}
309 %\hexboard{3}
310 %\hexcounter{b}{1}{A}
311 %\hexconnect{b}{1}{b}{2}
312 %\end{hexpicture}\end{verbatim}
313 %
314 %\begin{hexpicture}
315 % \hexboard{3}
316 % \hexcounter{b}{1}{A}
317 % \hexconnect{b}{1}{b}{2}
318 %\end{hexpicture}
319 %
320 %\subsection{Putting text or other content in a cell}
321 %
322 %The command \verb|\hexcontent{x}{y}{content}| puts \verb|content| into cell (\verb|x|,\verb|y|).
323 %
324 %For example, here we write ``b2'' in cell b2.
325 %
326 %\begin{verbatim}\begin{hexpicture}
327 %\hexboard{3}
328 %\hexcontent{b}{2}{b2}
329 %\end{hexpicture}\end{verbatim}
330 %
331 %\begin{hexpicture}
332 % \hexboard{3}
333 % \hexcontent{b}{2}{b2}
334 %\end{hexpicture}
335 %
336 %By default, the text is \verb|\scriptsize| (and then scaled by \verb|\hexscale|, see \ref{scaling}). This can be overridden.
337 %
338 %For example
339 %
340 %\begin{verbatim}\begin{hexpicture}
341 %\hexboard{3}
342 %\hexcontent{b}{2}{\tiny here}
343 %\end{hexpicture}\end{verbatim}
344 %
345 %\begin{hexpicture}
346 % \hexboard{3}
347 % \hexcontent{b}{2}{\tiny here}
348 %\end{hexpicture}
349 %
350 %The \verb|content| can contain other \LaTeX\ commands. For example
351 %
352 %\begin{verbatim}\usepackage{rotating}
353 %...
354 %\begin{hexpicture}
355 %\hexboard{9}
356 %\hexcontent{e}{5}{\begin{turn}{30}
357 %\colorbox{lightgray}{\color{blue}{\normalsize \textbf{Fancy a game?}}}
358 %\end{turn}}
359 %\end{hexpicture}\end{verbatim}
360 %
361 %
362 %\begin{hexpicture}
363 % \hexboard{9}
364 % \hexcontent{e}{5}{\begin{turn}{30}
365 % \colorbox{lightgray}{\color{blue}{\normalsize \textbf{Fancy a game?}}}
366 % \end{turn}}
367 %\end{hexpicture}
368 %
369 %\section{User configuration}
370 %
371 %\subsection{Scaling images}\label{scaling}
372 %
373 %The basic unit of the diagrams can be scaled using \verb|\hexscale{number}|. The default is 2.
374 %
375 %For example \verb|\hexscale{8}| changes this\\
376 %
377 %\begin{hexpicture}
378 % \hexcell{a}{1}
379 % \hexcellshaded{b}{1}
380 % \hexcellshaded{a}{2}
381 % \hexcell{b}{2}
382 % \hexcounter{a}{1}{A}
383 % \hexcounter{b}{2}{A}
384 % \hexdot{a}{2}
385 % \hexdot{b}{1}
386 % \hexconnect{a}{1}{a}{2}
387 % \hexconnect{a}{1}{b}{1}
388 % \hexconnect{a}{2}{b}{2}
389 % \hexconnect{b}{1}{b}{2}
390 %\end{hexpicture}
391 %
392 %into this\\
393 %
394 %\hexscale{8}
395 %\begin{hexpicture}
396 % \hexcell{a}{1}
397 % \hexcellshaded{b}{1}
398 % \hexcellshaded{a}{2}
399 % \hexcell{b}{2}
400 % \hexcounter{a}{1}{A}
401 % \hexcounter{b}{2}{A}
402 % \hexdot{a}{2}
403 % \hexdot{b}{1}
404 % \hexconnect{a}{1}{a}{2}
405 % \hexconnect{a}{1}{b}{1}
406 % \hexconnect{a}{2}{b}{2}
407 % \hexconnect{b}{1}{b}{2}
408 %\end{hexpicture}\\
409 %
410 %Fractional values are possible. For example
411 %
412 %\begin{verbatim}\hexscale{0.5}
413 %\begin{hexpicture}
414 %\hexboard{2}
415 %\hexcounter{a}{1}{A}
416 %\hexcounter{b}{2}{B}
417 %\end{hexpicture}\end{verbatim}
418 %
419 %\hexscale{0.5}
420 %\begin{hexpicture}
421 % \hexboard{2}
422 % \hexcounter{a}{1}{A}
423 % \hexcounter{b}{2}{B}
424 %\end{hexpicture}
425 %
426 %and
427 %
428 %\begin{verbatim}\hexscale{3.5}
429 %\begin{hexpicture}
430 %\hexboard{2}
431 %\hexcounter{a}{1}{A}
432 %\hexcounter{b}{2}{B}
433 %\end{hexpicture}\end{verbatim}
434 %
435 %\hexscale{3.5}
436 %\begin{hexpicture}
437 % \hexboard{2}
438 % \hexcounter{a}{1}{A}
439 % \hexcounter{b}{2}{B}
440 %\end{hexpicture}
441 %
442 %\hexscale{2}
443 %
444 %\subsection{Colours}
445 %
446 %Player A's colour can be set using \verb|\setcolorA{color}| and player B's colour can be set using \verb|\setcolorB{color}|. The defaults are \verb|red| for player A and \verb|blue| for player B.
447 %
448 %For example, for a greyscale diagram use
449 %
450 %\begin{verbatim}\setcolorA{lightgray}
451 %\setcolorB{darkgray}\end{verbatim}
452 %
453 %This changes this\\
454 %
455 %\begin{hexpicture}
456 % \hexboard{3}
457 % \hexcounter{a}{2}{B}
458 % \hexcounter{b}{3}{B}
459 % \hexcounter{c}{3}{A}
460 %\end{hexpicture}
461 %
462 %into this\\
463 %
464 %\setcolorA{lightgray}
465 %\setcolorB{darkgray}
466 %\begin{hexpicture}
467 % \hexboard{3}
468 % \hexcounter{a}{2}{B}
469 % \hexcounter{b}{3}{B}
470 % \hexcounter{c}{3}{A}
471 %\end{hexpicture}
472 %\setcolorA{red}
473 %\setcolorB{blue}
474 %
475 %To use the current user colours elsewhere in the document, access these as \verb|\colorA| and \verb|\colorB|. For example
476 %
477 %\begin{verbatim}
478 %{\color{\colorA} This text is player A's colour} and
479 %{\color{\colorB} This text is player B's colour}.
480 %
481 %\setcolorA{teal}
482 %\setcolorB{magenta}
483 %{\color{\colorA} This text is player A's colour} and
484 %{\color{\colorB} This text is player B's colour}.
485 %\end{verbatim}
486 %
487 %{\color{\colorA} This text is player A's colour} and
488 %{\color{\colorB} This text is player B's colour}.
489 %
490 %\setcolorA{teal}
491 %\setcolorB{magenta}
492 %{\color{\colorA} This text is player A's colour} and
493 %{\color{\colorB} This text is player B's colour}.
494 %\setcolorA{red}
495 %\setcolorB{blue}
496 %
497 %
498 %\section{Advanced use}
499 %
500 %\subsection{Drawing an irregular board}
501 %
502 %The command \verb|\hexgrid{columns}{rows}| is used to draw a grid of that size. In fact, the command \verb|\hexboard| is provided for convenience and simply calls \verb|\hexgrid| with the same number of \verb|rows| and \verb|columns|.
503 %
504 %For example
505 %
506 %\begin{verbatim}\begin{hexpicture}
507 %\hexgrid{9}{5}
508 %\end{hexpicture}\end{verbatim}
509 %
510 %\begin{hexpicture}
511 % \hexgrid{9}{5}
512 %\end{hexpicture}
513 %
514 %\subsection{Drawing a board with no edge labels}
515 %
516 %The command \verb|\hexgridnolabel{columns}{rows}| is used to draw a grid of that size without edge labels.
517 %
518 %For example
519 %
520 %\begin{verbatim}\begin{hexpicture}
521 %\hexgridnolabel{9}{5}
522 %\end{hexpicture}\end{verbatim}
523 %
524 %\begin{hexpicture}
525 % \hexgridnolabel{9}{5}
526 %\end{hexpicture}
527 %
528 %
529 %\subsection{Drawing a single cell}
530 %
531 %An individual cell is drawn using \verb|\hexcell{x}{y}|.
532 %
533 %For example
534 %
535 %\begin{verbatim}\begin{hexpicture}
536 %\hexcell{a}{1}
537 %\hexcell{b}{1}
538 %\hexcell{b}{2}
539 %\hexcell{c}{4}
540 %\end{hexpicture}\end{verbatim}
541 %
542 %\begin{hexpicture}
543 % \hexcell{a}{1}
544 % \hexcell{b}{1}
545 % \hexcell{b}{2}
546 % \hexcell{c}{4}
547 %\end{hexpicture}
548 %
549 %\subsection{Drawing a sub-row}
550 %
551 %The command \verb|\hexsubrow{start}{end}{row}| draws a partial row of cells from column \verb|start| to column \verb|end| on row \verb|row|.
552 %
553 %For example
554 %
555 %\begin{verbatim}\begin{hexpicture}
556 %\hexsubrow{b}{f}{1}
557 %\hexsubrow{a}{e}{2}
558 %\hexsubrow{a}{b}{3}
559 %\hexsubrow{d}{e}{3}
560 %\end{hexpicture}\end{verbatim}
561 %
562 %\begin{hexpicture}
563 % \hexsubrow{b}{f}{1}
564 % \hexsubrow{a}{e}{2}
565 % \hexsubrow{a}{b}{3}
566 % \hexsubrow{d}{e}{3}
567 %\end{hexpicture}
568 %
569 %\subsection{Shading a sub-row}
570 %
571 %The command \verb|\hexshadedsubrow{start}{end}{row}| draws a partial row of shaded cells from column \verb|start| to column \verb|end| on row \verb|row|.
572 %
573 %For example
574 %
575 %\begin{verbatim}\begin{hexpicture}
576 %\hexgrid{6}{4}
577 %\hexshadedsubrow{b}{d}{2}
578 %\hexshadedsubrow{c}{e}{3}
579 %\end{hexpicture}\end{verbatim}
580 %
581 %\begin{hexpicture}
582 % \hexgrid{6}{4}
583 % \hexshadedsubrow{b}{d}{2}
584 % \hexshadedsubrow{c}{e}{3}
585 %\end{hexpicture}
586 %
587 %\subsection{Drawing a partial bottom border}
588 %
589 %The command \verb|\hexbottomsubborder{start}{end}| draws a bottom border from column \verb|start| to column \verb|end|.
590 %
591 %For example
592 %
593 %\begin{verbatim}\begin{hexpicture}
594 %\hexsubrow{b}{f}{1}
595 %\hexsubrow{a}{e}{2}
596 %\hexsubrow{a}{d}{3}
597 %\hexbottomsubborder{b}{f}
598 %\end{hexpicture}\end{verbatim}
599 %
600 %\begin{hexpicture}
601 % \hexsubrow{b}{f}{1}
602 % \hexsubrow{a}{e}{2}
603 % \hexsubrow{a}{d}{3}
604 % \hexbottomsubborder{b}{f}
605 %\end{hexpicture}
606 %
607 %\subsection{Drawing a reducing part-board}
608 %
609 %The command \verb|\hexreducing{columns}{rows}| draws a grid with a bottom border only that starts at \verb|columns| wide but decreases width by 1 each row until it has drawn \verb|rows| rows.
610 %
611 %For example
612 %
613 %\begin{verbatim}\begin{hexpicture}
614 %\hexreducing{6}{3}
615 %\end{hexpicture}\end{verbatim}
616 %
617 %\begin{hexpicture}
618 % \hexreducing{6}{3}
619 %\end{hexpicture}
620 %
621 %You can also draw a reducing board without a bottom coloured border using\\
622 %\verb|\hexreducingnoborder{columns}{rows}|.
623 %
624 %For example
625 %
626 %\begin{verbatim}\begin{hexpicture}
627 %\hexreducingnoborder{5}{4}
628 %\end{hexpicture}\end{verbatim}
629 %
630 %\begin{hexpicture}
631 % \hexreducingnoborder{5}{4}
632 %\end{hexpicture}
633 %
634 %\subsection{A note about board size}
635 %
636 %A 1 by 1 Hex board is possible.
637 %
638 %\begin{verbatim}\begin{hexpicture}
639 %\hexboard{1}
640 %\end{hexpicture}\end{verbatim}
641 %
642 %\begin{hexpicture}
643 % \hexboard{1}
644 %\end{hexpicture}\\
645 %
646 %By extension, irregular boards which are a single column or row are possible.
647 %
648 %\begin{verbatim}\begin{hexpicture}
649 %\hexgrid{1}{4}
650 %\end{hexpicture}\end{verbatim}
651 %
652 %\begin{hexpicture}
653 % \hexgrid{1}{4}
654 %\end{hexpicture}
655 %
656 %\begin{verbatim}\begin{hexpicture}
657 %\hexgrid{7}{1}
658 %\end{hexpicture}\end{verbatim}
659 %
660 %\begin{hexpicture}
661 % \hexgrid{7}{1}
662 %\end{hexpicture}
663 %
664 %Theoretically there is no maximum size of the board, though note the board will happily move beyond the size of the paper, and references to cells beyond column \verb|z| are by number only, both when referring to coordinates and in the bottom edge labels.
665 %
666 %For example
667 %
668 %\begin{verbatim}\hexscale{1.4}
669 %\begin{hexpicture}
670 %\hexgrid{27}{4}
671 %\hexcounter{z}{4}{A}
672 %\hexcounter{27}{4}{B}
673 %\end{hexpicture}\end{verbatim}
674 %
675 %\hexscale{1.4}
676 %\begin{hexpicture}
677 % \hexgrid{27}{4}
678 % \hexcounter{z}{4}{A}
679 % \hexcounter{27}{4}{B}
680 %\end{hexpicture}
681 %
682 %\hexscale{2}
683 %
684 %\subsection{Use with tikz}
685 %
686 %The package uses tikz and \verb|\usetikzlibrary{shapes.geometric}|. The definition of \verb|hexpicture| (also used by \verb|hexgame|) is
687 %
688 %\verb|\newenvironment{hexpicture}{\begin{tikzpicture}[hex]}{\end{tikzpicture}}|
689 %
690 %In theory, then, any tikz commands that will work in this context can be used.
691 %
692 %Note that the diagrams were made based around one cell being 1em across. This leads to quite small diagrams, hence the default for \verb|\hexscale| being set to \verb|2|. This means that it is best to give tikz commands in ems, and has unfortunate consequences for example on text size. In the following example, the label is positioned using \verb|(14em,3em)| and the text is \verb|\tiny| for this reason.
693 %
694 %\begin{verbatim}\begin{hexpicture}
695 %\hexshadedsubrow{b}{h}{1}
696 %\hexshadedsubrow{b}{g}{2}
697 %\hexshadedsubrow{b}{f}{3}
698 %\hexshadedsubrow{c}{d}{4}
699 %\hexreducing{9}{5}
700 %\hexcounter{c}{4}{A}
701 %\hexdot{c}{3}
702 %\hexdot{e}{3}
703 %\hexconnect{c}{4}{c}{3}
704 %\hexconnect{c}{4}{d}{3}
705 %\hexconnect{d}{3}{e}{3}
706 %\hexconnect{c}{4}{d}{4}
707 %\hexconnect{d}{4}{e}{3}
708 %\hexcontent{e}{1}{?}
709 %\node at (14em,3em) {\parbox{5em}{\tiny Consider what happens if blue puts a
710 %piece in the hex marked ``?''.}};
711 %\end{hexpicture}\end{verbatim}
712 %
713 %\begin{hexpicture}
714 % \hexshadedsubrow{b}{h}{1}
715 % \hexshadedsubrow{b}{g}{2}
716 % \hexshadedsubrow{b}{f}{3}
717 % \hexshadedsubrow{c}{d}{4}
718 % \hexreducing{9}{5}
719 % \hexcounter{c}{4}{A}
720 % \hexdot{c}{3}
721 % \hexdot{e}{3}
722 % \hexconnect{c}{4}{c}{3}
723 % \hexconnect{c}{4}{d}{3}
724 % \hexconnect{d}{3}{e}{3}
725 % \hexconnect{c}{4}{d}{4}
726 % \hexconnect{d}{4}{e}{3}
727 % \hexcontent{e}{1}{?}
728 % \node at (14em,3em) {\parbox{5em}{\tiny Consider what happens if blue puts a piece in the hex marked ``?''.}};
729 %\end{hexpicture}\\
730 %
731 %If you wish to draw tikz items relative to the grid, it may be useful to know that the centre of any cell on the grid can be determined using \verb|\hexcoord{x}{y}|. This command sets \verb|\xchor| and \verb|\ychor| to be the centre of the cell at (\verb|x|,\verb|y|), then these coordinates can be used in further commands.
732 %
733 %So if you for some reason wanted a pinkish-purple box aligned with certain cells of your Hex grid, you could do this.
734 %
735 %\begin{verbatim}\definecolor{lavendermist}{rgb}{0.9, 0.9, 0.98}
736 %\definecolor{lavenderpink}{rgb}{0.98, 0.68, 0.82}
737 %\definecolor{lavenderpurple}{rgb}{0.59, 0.48, 0.71}
738 %\begin{hexpicture}
739 %\hexboard{5}
740 %\hexcoord{c}{2}
741 %\node (n1) at (\xchor em,\ychor em) {};
742 %\hexcoord{d}{4}
743 %\node (n2) at (\xchor em,\ychor em) {};
744 %\draw[ultra thick,lavenderpink,left color=lavenderpurple,right
745 %color=lavendermist] (n1) rectangle (n2);
746 %\end{hexpicture}\end{verbatim}
747 %
748 %\definecolor{lavendermist}{rgb}{0.9, 0.9, 0.98}
749 %\definecolor{lavenderpink}{rgb}{0.98, 0.68, 0.82}
750 %\definecolor{lavenderpurple}{rgb}{0.59, 0.48, 0.71}
751 %\begin{hexpicture}
752 % \hexboard{5}
753 % \hexcoord{c}{2}
754 % \node (n1) at (\xchor em,\ychor em) {};
755 % \hexcoord{d}{4}
756 % \node (n2) at (\xchor em,\ychor em) {};
757 % \draw[ultra thick,lavenderpink,left color=lavenderpurple,right color=lavendermist] (n1) rectangle (n2);
758 %\end{hexpicture}
759 %
760 %\subsection{Internal}
761 %
762 %Various internal commands are used:
763 %
764 %\verb|hexedge| (counter)
765 %
766 %\verb|hexmovecount| (counter)
767 %
768 %\verb|\xchor|
769 %
770 %\verb|\ychor|
771 %
772 %\verb|\colorA|
773 %
774 %\verb|\colorB|
775 %
776 %\verb|\hexlinewidth|
777 %
778 %\verb|\hexedgewidth|
779 %
780 %\verb|\hexthinline|
781 %
782 %\verb|\hexcoord|
783 %
784 %\verb|\hexsize|
785 %
786 %\verb|\Ia|
787 %
788 %\verb|\Ib|
789 %
790 %\verb|\Iaend|
791 %
792 %\verb|\leftofIa|
793 %
794 %\verb|\belowIa|
795 %
796 %\verb|\leftofxchor|
797 %
798 %\section{Some examples}
799 %
800 %\begin{verbatim}\begin{hexpicture}
801 %\hexcell{a}{1}
802 %\hexcellshaded{b}{1}
803 %\hexcellshaded{a}{2}
804 %\hexcell{b}{2}
805 %\hexcounter{a}{1}{A}
806 %\hexcounter{b}{2}{A}
807 %\hexdot{a}{2}
808 %\hexdot{b}{1}
809 %\hexconnect{a}{1}{a}{2}
810 %\hexconnect{a}{1}{b}{1}
811 %\hexconnect{a}{2}{b}{2}
812 %\hexconnect{b}{1}{b}{2}
813 %\end{hexpicture}\end{verbatim}
814 %
815 %\begin{hexpicture}
816 % \hexcell{a}{1}
817 % \hexcellshaded{b}{1}
818 % \hexcellshaded{a}{2}
819 % \hexcell{b}{2}
820 % \hexcounter{a}{1}{A}
821 % \hexcounter{b}{2}{A}
822 % \hexdot{a}{2}
823 % \hexdot{b}{1}
824 % \hexconnect{a}{1}{a}{2}
825 % \hexconnect{a}{1}{b}{1}
826 % \hexconnect{a}{2}{b}{2}
827 % \hexconnect{b}{1}{b}{2}
828 %\end{hexpicture}
829 %
830 %\begin{verbatim}\begin{hexpicture}
831 %\hexshadedsubrow{b}{c}{1}
832 %\hexreducing{4}{2}
833 %\hexcounter{b}{2}{A}
834 %\hexdot{b}{1}
835 %\hexdot{c}{1}
836 %\hexconnect{b}{2}{b}{1}
837 %\hexconnect{b}{2}{c}{1}
838 %\end{hexpicture}\end{verbatim}
839 %
840 %\begin{hexpicture}
841 % \hexshadedsubrow{b}{c}{1}
842 % \hexreducing{4}{2}
843 % \hexcounter{b}{2}{A}
844 % \hexdot{b}{1}
845 % \hexdot{c}{1}
846 % \hexconnect{b}{2}{b}{1}
847 % \hexconnect{b}{2}{c}{1}
848 %\end{hexpicture}
849 %
850 %\begin{verbatim}\begin{hexpicture}
851 %\hexshadedsubrow{b}{e}{1}
852 %\hexshadedsubrow{b}{d}{2}
853 %\hexshadedsubrow{b}{c}{3}
854 %\hexreducing{6}{4}
855 %\hexcounter{b}{3}{A}
856 %\hexdot{b}{2}
857 %\hexdot{d}{2}
858 %\hexconnect{b}{3}{b}{2}
859 %\hexconnect{b}{3}{c}{2}
860 %\hexconnect{c}{2}{d}{2}
861 %\hexconnect{b}{3}{c}{3}
862 %\hexconnect{c}{3}{d}{2}
863 %\end{hexpicture}\end{verbatim}
864 %
865 %\begin{hexpicture}
866 % \hexshadedsubrow{b}{e}{1}
867 % \hexshadedsubrow{b}{d}{2}
868 % \hexshadedsubrow{b}{c}{3}
869 % \hexreducing{6}{4}
870 % \hexcounter{b}{3}{A}
871 % \hexdot{b}{2}
872 % \hexdot{d}{2}
873 % \hexconnect{b}{3}{b}{2}
874 % \hexconnect{b}{3}{c}{2}
875 % \hexconnect{c}{2}{d}{2}
876 % \hexconnect{b}{3}{c}{3}
877 % \hexconnect{c}{3}{d}{2}
878 %\end{hexpicture}
879 %
880 %
881 %\begin{verbatim}\begin{hexpicture}
882 %\hexshadedsubrow{b}{c}{1}
883 %\hexshadedsubrow{e}{f}{1}
884 %\hexshadedsubrow{b}{e}{2}
885 %\hexshadedsubrow{b}{d}{3}
886 %\hexreducing{7}{4}
887 %\hexcounter{c}{3}{A}
888 %\hexdot{b}{2}
889 %\hexdot{e}{2}
890 %\hexconnect{b}{2}{c}{2}
891 %\hexconnect{b}{3}{b}{2}
892 %\hexconnect{c}{3}{b}{3}
893 %\hexconnect{c}{3}{c}{2}
894 %\hexconnect{c}{3}{d}{2}
895 %\hexconnect{d}{2}{e}{2}
896 %\hexconnect{c}{3}{d}{3}
897 %\hexconnect{d}{3}{e}{2}
898 %\end{hexpicture}\end{verbatim}
899 %
900 %\begin{hexpicture}
901 % \hexshadedsubrow{b}{c}{1}
902 % \hexshadedsubrow{e}{f}{1}
903 % \hexshadedsubrow{b}{e}{2}
904 % \hexshadedsubrow{b}{d}{3}
905 % \hexreducing{7}{4}
906 % \hexcounter{c}{3}{A}
907 % \hexdot{b}{2}
908 % \hexdot{e}{2}
909 % \hexconnect{b}{2}{c}{2}
910 % \hexconnect{b}{3}{b}{2}
911 % \hexconnect{c}{3}{b}{3}
912 % \hexconnect{c}{3}{c}{2}
913 % \hexconnect{c}{3}{d}{2}
914 % \hexconnect{d}{2}{e}{2}
915 % \hexconnect{c}{3}{d}{3}
916 % \hexconnect{d}{3}{e}{2}
917 %\end{hexpicture}
918 %
919 %\begin{verbatim}\begin{hexpicture}
920 %\hexshadedsubrow{b}{i}{1}
921 %\hexshadedsubrow{b}{d}{2}
922 %\hexshadedsubrow{f}{h}{2}
923 %\hexshadedsubrow{b}{g}{3}
924 %\hexshadedsubrow{c}{e}{4}
925 %\hexreducing{10}{5}
926 %\hexcounter{d}{4}{A}
927 %\hexdot{c}{3}
928 %\hexdot{f}{3}
929 %\hexconnect{c}{3}{d}{3}
930 %\hexconnect{c}{4}{c}{3}
931 %\hexconnect{d}{4}{c}{4}
932 %\hexconnect{d}{4}{d}{3}
933 %\hexconnect{d}{4}{e}{3}
934 %\hexconnect{e}{3}{f}{3}
935 %\hexconnect{d}{4}{e}{4}
936 %\hexconnect{e}{4}{f}{3}
937 %\end{hexpicture}\end{verbatim}
938 %
939 %\begin{hexpicture}
940 % \hexshadedsubrow{b}{i}{1}
941 % \hexshadedsubrow{b}{d}{2}
942 % \hexshadedsubrow{f}{h}{2}
943 % \hexshadedsubrow{b}{g}{3}
944 % \hexshadedsubrow{c}{e}{4}
945 % \hexreducing{10}{5}
946 % \hexcounter{d}{4}{A}
947 % \hexdot{c}{3}
948 % \hexdot{f}{3}
949 % \hexconnect{c}{3}{d}{3}
950 % \hexconnect{c}{4}{c}{3}
951 % \hexconnect{d}{4}{c}{4}
952 % \hexconnect{d}{4}{d}{3}
953 % \hexconnect{d}{4}{e}{3}
954 % \hexconnect{e}{3}{f}{3}
955 % \hexconnect{d}{4}{e}{4}
956 % \hexconnect{e}{4}{f}{3}
957 %\end{hexpicture}
958 %
959 %\begin{verbatim}\begin{hexpicture}
960 %\hexsubrow{b}{f}{1}
961 %\hexsubrow{a}{e}{2}
962 %\hexsubrow{a}{d}{3}
963 %\hexsubrow{a}{c}{4}
964 %\hexshadedsubrow{c}{e}{1}
965 %\hexshadedsubrow{b}{d}{2}
966 %\hexshadedsubrow{b}{c}{3}
967 %\hexbottomsubborder{b}{f}
968 %\hexcounter{b}{3}{A}
969 %\hexcounter{c}{3}{A}
970 %\end{hexpicture}\end{verbatim}
971 %
972 %\begin{hexpicture}
973 % \hexsubrow{b}{f}{1}
974 % \hexsubrow{a}{e}{2}
975 % \hexsubrow{a}{d}{3}
976 % \hexsubrow{a}{c}{4}
977 % \hexshadedsubrow{c}{e}{1}
978 % \hexshadedsubrow{b}{d}{2}
979 % \hexshadedsubrow{b}{c}{3}
980 % \hexbottomsubborder{b}{f}
981 % \hexcounter{b}{3}{A}
982 % \hexcounter{c}{3}{A}
983 %\end{hexpicture}
984 %
985 %\begin{verbatim}\begin{hexpicture}
986 %\hexsubrow{b}{g}{1}
987 %\hexsubrow{b}{f}{2}
988 %\hexsubrow{a}{e}{3}
989 %\hexsubrow{a}{d}{4}
990 %\hexshadedsubrow{c}{f}{1}
991 %\hexshadedsubrow{c}{e}{2}
992 %\hexshadedsubrow{b}{d}{3}
993 %\hexshadedsubrow{b}{c}{4}
994 %\hexbottomsubborder{b}{g}
995 %\hexcounter{b}{4}{A}
996 %\hexcounter{c}{4}{A}
997 %\end{hexpicture}\end{verbatim}
998 %
999 %\begin{hexpicture}
1000 % \hexsubrow{b}{g}{1}
1001 % \hexsubrow{b}{f}{2}
1002 % \hexsubrow{a}{e}{3}
1003 % \hexsubrow{a}{d}{4}
1004 % \hexshadedsubrow{c}{f}{1}
1005 % \hexshadedsubrow{c}{e}{2}
1006 % \hexshadedsubrow{b}{d}{3}
1007 % \hexshadedsubrow{b}{c}{4}
1008 % \hexbottomsubborder{b}{g}
1009 % \hexcounter{b}{4}{A}
1010 % \hexcounter{c}{4}{A}
1011 %\end{hexpicture}
1012 %
1013 %\begin{verbatim}\begin{hexpicture}
1014 %\hexboard{3}
1015 %\hexcounter{a}{2}{B}
1016 %\hexcounter{b}{3}{B}
1017 %\hexcounter{c}{3}{A}
1018 %\end{hexpicture}\end{verbatim}
1019 %
1020 %\begin{hexpicture}
1021 % \hexboard{3}
1022 % \hexcounter{a}{2}{B}
1023 % \hexcounter{b}{3}{B}
1024 % \hexcounter{c}{3}{A}
1025 %\end{hexpicture}
1026 %
1027 %\begin{verbatim}\begin{hexpicture}
1028 %\hexboard{4}
1029 %\hexcounter{d}{1}{B}
1030 %\hexcounter{a}{1}{A}
1031 %\end{hexpicture}\end{verbatim}
1032 %
1033 %\begin{hexpicture}
1034 % \hexboard{4}
1035 % \hexcounter{d}{1}{B}
1036 % \hexcounter{a}{1}{A}
1037 %\end{hexpicture}
1038 %
1039 %\begin{verbatim}\begin{hexpicture}
1040 %\hexboard{5}
1041 %\hexcounter{b}{1}{B}
1042 %\hexcounter{c}{2}{B}
1043 %\hexcounter{d}{2}{B}
1044 %\hexcounter{c}{1}{A}
1045 %\hexcounter{e}{1}{A}
1046 %\hexcounter{c}{3}{A}
1047 %\end{hexpicture}\end{verbatim}
1048 %
1049 %\begin{hexpicture}
1050 % \hexboard{5}
1051 % \hexcounter{b}{1}{B}
1052 % \hexcounter{c}{2}{B}
1053 % \hexcounter{d}{2}{B}
1054 % \hexcounter{c}{1}{A}
1055 % \hexcounter{e}{1}{A}
1056 % \hexcounter{c}{3}{A}
1057 %\end{hexpicture}
1058 %
1059 %\begin{verbatim}\begin{hexpicture}
1060 %\hexboard{11}
1061 %\hexcounter{a}{4}{B}
1062 %\hexcounter{b}{4}{B}
1063 %\hexcounter{c}{4}{B}
1064 %\hexcounter{d}{4}{B}
1065 %\hexcounter{e}{4}{B}
1066 %\hexcounter{f}{4}{B}
1067 %\hexcounter{g}{4}{B}
1068 %\hexcounter{h}{4}{A}
1069 %\hexcounter{i}{4}{B}
1070 %\hexcounter{j}{4}{B}
1071 %\hexcounter{k}{4}{B}
1072 %\hexcounter{b}{3}{A}
1073 %\hexcounter{f}{8}{B}
1074 %\hexcounter{g}{8}{B}
1075 %\hexcounter{i}{8}{A}
1076 %\hexcounter{d}{9}{A}
1077 %\end{hexpicture}\end{verbatim}
1078 %
1079 %\begin{hexpicture}
1080 % \hexboard{11}
1081 % \hexcounter{a}{4}{B}
1082 % \hexcounter{b}{4}{B}
1083 % \hexcounter{c}{4}{B}
1084 % \hexcounter{d}{4}{B}
1085 % \hexcounter{e}{4}{B}
1086 % \hexcounter{f}{4}{B}
1087 % \hexcounter{g}{4}{B}
1088 % \hexcounter{h}{4}{A}
1089 % \hexcounter{i}{4}{B}
1090 % \hexcounter{j}{4}{B}
1091 % \hexcounter{k}{4}{B}
1092 % \hexcounter{b}{3}{A}
1093 % \hexcounter{f}{8}{B}
1094 % \hexcounter{g}{8}{B}
1095 % \hexcounter{i}{8}{A}
1096 % \hexcounter{d}{9}{A}
1097 %\end{hexpicture}
1098 %
1099 %\begin{verbatim}\begin{hexpicture}
1100 %\hexsubrow{b}{c}{1}
1101 %\hexsubrow{a}{c}{2}
1102 %\hexsubrow{a}{b}{3}
1103 %
1104 %\hexsubrow{f}{g}{1}
1105 %\hexsubrow{e}{g}{2}
1106 %\hexsubrow{e}{f}{3}
1107 %
1108 %\hexsubrow{j}{k}{1}
1109 %\hexsubrow{i}{k}{2}
1110 %\hexsubrow{i}{j}{3}
1111 %
1112 %\hexcounter{b}{2}{A}
1113 %\hexcounter{b}{1}{B}
1114 %\hexcounter{c}{1}{A}
1115 %
1116 %\hexcontent{d}{2}{\(\to\)}
1117 %
1118 %\hexcounter{f}{2}{A}
1119 %\hexcounter{f}{1}{B}
1120 %\hexcounter{g}{1}{A}
1121 %\hexcounter{f}{3}{B}
1122 %
1123 %\hexcontent{h}{2}{\(\to\)}
1124 %
1125 %\hexcounter{j}{2}{A}
1126 %\hexcounter{j}{1}{B}
1127 %\hexcounter{k}{1}{A}
1128 %\hexcounter{j}{3}{B}
1129 %\hexcounter{i}{3}{A}
1130 %\end{hexpicture}\end{verbatim}
1131 %
1132 %\begin{hexpicture}
1133 % \hexsubrow{b}{c}{1}
1134 % \hexsubrow{a}{c}{2}
1135 % \hexsubrow{a}{b}{3}
1136 %
1137 % \hexsubrow{f}{g}{1}
1138 % \hexsubrow{e}{g}{2}
1139 % \hexsubrow{e}{f}{3}
1140 %
1141 % \hexsubrow{j}{k}{1}
1142 % \hexsubrow{i}{k}{2}
1143 % \hexsubrow{i}{j}{3}
1144 %
1145 % \hexcounter{b}{2}{A}
1146 % \hexcounter{b}{1}{B}
1147 % \hexcounter{c}{1}{A}
1148 %
1149 % \hexcontent{d}{2}{\(\to\)}
1150 %
1151 % \hexcounter{f}{2}{A}
1152 % \hexcounter{f}{1}{B}
1153 % \hexcounter{g}{1}{A}
1154 % \hexcounter{f}{3}{B}
1155 %
1156 % \hexcontent{h}{2}{\(\to\)}
1157 %
1158 % \hexcounter{j}{2}{A}
1159 % \hexcounter{j}{1}{B}
1160 % \hexcounter{k}{1}{A}
1161 % \hexcounter{j}{3}{B}
1162 % \hexcounter{i}{3}{A}
1163 %\end{hexpicture}
1164 %
1165 %\section{Other games}
1166 %
1167 %The target of this package is Hex. However, notice that some games on a hexagonal grid can be created using the commands provided here with cells shaded and counters, dots and lines placed in the usual way.
1168 %
1169 %For example, Y is played on a reducing hexagonal grid that can be created using \verb|\hexreducingnoborder|. For example
1170 %
1171 %\begin{verbatim}\begin{hexpicture}
1172 %\hexreducingnoborder{11}{11}
1173 %\end{hexpicture}\end{verbatim}
1174 %
1175 %\begin{hexpicture}
1176 % \hexreducingnoborder{11}{11}
1177 %\end{hexpicture}\\
1178 %
1179 %Similarly, games such as Cross, Pentalath, Yavalath and Three Player Hex can be played on a hexagonal board without coloured borders which can be created via use of \verb|\hexsubrow|.
1180 %
1181 %\begin{verbatim}\begin{hexpicture}
1182 %\hexsubrow{a}{g}{13}
1183 %\hexsubrow{a}{h}{12}
1184 %\hexsubrow{a}{i}{11}
1185 %\hexsubrow{a}{j}{10}
1186 %\hexsubrow{a}{k}{9}
1187 %\hexsubrow{a}{l}{8}
1188 %\hexsubrow{a}{m}{7}
1189 %\hexsubrow{b}{m}{6}
1190 %\hexsubrow{c}{m}{5}
1191 %\hexsubrow{d}{m}{4}
1192 %\hexsubrow{e}{m}{3}
1193 %\hexsubrow{f}{m}{2}
1194 %\hexsubrow{g}{m}{1}
1195 %\end{hexpicture}\end{verbatim}
1196 %
1197 %\begin{hexpicture}
1198 % \hexsubrow{a}{g}{13}
1199 % \hexsubrow{a}{h}{12}
1200 % \hexsubrow{a}{i}{11}
1201 % \hexsubrow{a}{j}{10}
1202 % \hexsubrow{a}{k}{9}
1203 % \hexsubrow{a}{l}{8}
1204 % \hexsubrow{a}{m}{7}
1205 % \hexsubrow{b}{m}{6}
1206 % \hexsubrow{c}{m}{5}
1207 % \hexsubrow{d}{m}{4}
1208 % \hexsubrow{e}{m}{3}
1209 % \hexsubrow{f}{m}{2}
1210 % \hexsubrow{g}{m}{1}
1211 %\end{hexpicture}
1212 %
1213 %If desired, certain cells can be shaded in the usual way.
1214 %
1215 %\begin{verbatim}\begin{hexpicture}
1216 %\hexsubrow{a}{g}{13}
1217 %\hexsubrow{a}{h}{12}
1218 %\hexsubrow{a}{i}{11}
1219 %\hexsubrow{a}{j}{10}
1220 %\hexsubrow{a}{k}{9}
1221 %\hexsubrow{a}{l}{8}
1222 %\hexsubrow{a}{m}{7}
1223 %\hexsubrow{b}{m}{6}
1224 %\hexsubrow{c}{m}{5}
1225 %\hexsubrow{d}{m}{4}
1226 %\hexsubrow{e}{m}{3}
1227 %\hexsubrow{f}{m}{2}
1228 %\hexsubrow{g}{m}{1}
1229 %\hexshadedsubrow{g}{l}{2}
1230 %\hexcellshaded{f}{3}
1231 %\hexcellshaded{l}{3}
1232 %\hexcellshaded{e}{4}
1233 %\hexcellshaded{l}{4}
1234 %\hexcellshaded{d}{5}
1235 %\hexcellshaded{l}{5}
1236 %\hexcellshaded{c}{6}
1237 %\hexcellshaded{l}{6}
1238 %\hexcellshaded{b}{7}
1239 %\hexcellshaded{l}{7}
1240 %\hexcellshaded{b}{8}
1241 %\hexcellshaded{k}{8}
1242 %\hexcellshaded{b}{9}
1243 %\hexcellshaded{j}{9}
1244 %\hexcellshaded{b}{10}
1245 %\hexcellshaded{i}{10}
1246 %\hexcellshaded{b}{11}
1247 %\hexcellshaded{h}{11}
1248 %\hexshadedsubrow{b}{g}{12}
1249 %\end{hexpicture}\end{verbatim}
1250 %
1251 %\begin{hexpicture}
1252 % \hexsubrow{a}{g}{13}
1253 % \hexsubrow{a}{h}{12}
1254 % \hexsubrow{a}{i}{11}
1255 % \hexsubrow{a}{j}{10}
1256 % \hexsubrow{a}{k}{9}
1257 % \hexsubrow{a}{l}{8}
1258 % \hexsubrow{a}{m}{7}
1259 % \hexsubrow{b}{m}{6}
1260 % \hexsubrow{c}{m}{5}
1261 % \hexsubrow{d}{m}{4}
1262 % \hexsubrow{e}{m}{3}
1263 % \hexsubrow{f}{m}{2}
1264 % \hexsubrow{g}{m}{1}
1265 % \hexshadedsubrow{g}{l}{2}
1266 % \hexcellshaded{f}{3}
1267 % \hexcellshaded{l}{3}
1268 % \hexcellshaded{e}{4}
1269 % \hexcellshaded{l}{4}
1270 % \hexcellshaded{d}{5}
1271 % \hexcellshaded{l}{5}
1272 % \hexcellshaded{c}{6}
1273 % \hexcellshaded{l}{6}
1274 % \hexcellshaded{b}{7}
1275 % \hexcellshaded{l}{7}
1276 % \hexcellshaded{b}{8}
1277 % \hexcellshaded{k}{8}
1278 % \hexcellshaded{b}{9}
1279 % \hexcellshaded{j}{9}
1280 % \hexcellshaded{b}{10}
1281 % \hexcellshaded{i}{10}
1282 % \hexcellshaded{b}{11}
1283 % \hexcellshaded{h}{11}
1284 % \hexshadedsubrow{b}{g}{12}
1285 %\end{hexpicture}
1286 %\iffalse
1287 %<*documentation>
1288 \documentclass[a4paper]{article}
1289 \usepackage{a4wide}
1290 \usepackage{upquote}
1291 \usepackage{hexboard}
1292 \usepackage{doc}
1293 \usepackage{rotating}
1294 \usepackage{hyperref}
1295 \begin{document}
1296 \DocInput{hexboard.dtx}
1297 \end{document}
1298 %</documentation>
1299 %\fi
1300 %\iffalse
1301 %<*hexboard>
1302 \ProvidesPackage{hexboard}[2022/02/19 hexboard 1.0]
1303
1304 \RequirePackage{tikz}
1305 \usetikzlibrary{shapes.geometric}
1306 \RequirePackage{xstring}
1307
1308 \makeatletter
1309 \@ifundefined{c@hexedge}{}
1310 {\PackageWarning{hexboard}{Counter `hexedge' already defined}}
1311 \@ifundefined{c@hexmovecount}{}
1312 {\PackageWarning{hexboard}{Counter `hexmovecount' already defined}}
1313 \@ifundefined{c@hexmoveskips}{}
1314 {\PackageWarning{hexboard}{Counter `hexmoveskips' already defined}}
1315 \@ifundefined{c@hexletternum}{}
1316 {\PackageWarning{hexboard}{Counter `hexletternum' already defined}}
1317 \@ifundefined{hexboard}{}
1318 {\PackageWarning{hexboard}{command `hexboard' already defined}}
1319 \@ifundefined{hexcounter}{}
1320 {\PackageWarning{hexboard}{command `hexcounter' already defined}}
1321 \@ifundefined{hexcellshaded}{}
1322 {\PackageWarning{hexboard}{command `hexcellshaded' already defined}}
1323 \@ifundefined{hexdot}{}
1324 {\PackageWarning{hexboard}{command `hexdot' already defined}}
1325 \@ifundefined{hexconnect}{}
1326 {\PackageWarning{hexboard}{command `hexconnect' already defined}}
1327 \@ifundefined{hexcontent}{}
1328 {\PackageWarning{hexboard}{command `hexcontent' already defined}}
1329 \@ifundefined{hexcell}{}
1330 {\PackageWarning{hexboard}{command `hexcell' already defined}}
1331 \@ifundefined{hexgridnolabel}{}
1332 {\PackageWarning{hexboard}{command `hexgridnolabel' already defined}}
1333 \@ifundefined{hexreducing}{}
1334 {\PackageWarning{hexboard}{command `hexreducing' already defined}}
1335 \@ifundefined{hexshadedsubrow}{}
1336 {\PackageWarning{hexboard}{command `hexshadedsubrow' already defined}}
1337 \@ifundefined{hexgrid}{}
1338 {\PackageWarning{hexboard}{command `hexgrid' already defined}}
1339 \@ifundefined{setcolorA}{}
1340 {\PackageWarning{hexboard}{command `setcolorA' already defined}}
1341 \@ifundefined{setcolorB}{}
1342 {\PackageWarning{hexboard}{command `setcolorB' already defined}}
1343 \@ifundefined{hexscale}{}
1344 {\PackageWarning{hexboard}{command `hexscale' already defined}}
1345 \@ifundefined{xchor}{}
1346 {\PackageWarning{hexboard}{command `xchor' already defined}}
1347 \@ifundefined{ychor}{}
1348 {\PackageWarning{hexboard}{command `ychor' already defined}}
1349 \@ifundefined{colorA}{}
1350 {\PackageWarning{hexboard}{command `colorA' already defined}}
1351 \@ifundefined{colorB}{}
1352 {\PackageWarning{hexboard}{command `colorB' already defined}}
1353 \@ifundefined{hexlinewidth}{}
1354 {\PackageWarning{hexboard}{command `hexlinewidth' already defined}}
1355 \@ifundefined{hexedgewidth}{}
1356 {\PackageWarning{hexboard}{command `hexedgewidth' already defined}}
1357 \@ifundefined{hexthinline}{}
1358 {\PackageWarning{hexboard}{command `hexthinline' already defined}}
1359 \@ifundefined{hexcoord}{}
1360 {\PackageWarning{hexboard}{command `hexcoord' already defined}}
1361 \@ifundefined{hexsize}{}
1362 {\PackageWarning{hexboard}{command `hexsize' already defined}}
1363 \@ifundefined{Ia}{}
1364 {\PackageWarning{hexboard}{command `Ia' already defined}}
1365 \@ifundefined{Ib}{}
1366 {\PackageWarning{hexboard}{command `Ib' already defined}}
1367 \@ifundefined{Iaend}{}
1368 {\PackageWarning{hexboard}{command `Iaend' already defined}}
1369 \@ifundefined{leftofIa}{}
1370 {\PackageWarning{hexboard}{command `leftofIa' already defined}}
1371 \@ifundefined{belowIa}{}
1372 {\PackageWarning{hexboard}{command `belowIa' already defined}}
1373 \@ifundefined{leftofxchor}{}
1374 {\PackageWarning{hexboard}{command `leftofxchor' already defined}}
1375 \@ifundefined{hexgame}{}
1376 {\PackageWarning{hexboard}{command `hexgame' already defined}}
1377 \@ifundefined{hexgamelabels}{}
1378 {\PackageWarning{hexboard}{command `hexgamelabels' already defined}}
1379 \@ifundefined{hexthismover}{}
1380 {\PackageWarning{hexboard}{command `hexthismover' already defined}}
1381 \@ifundefined{hexmove}{}
1382 {\PackageWarning{hexboard}{command `hexmove' already defined}}
1383 \@ifundefined{hexletter}{}
1384 {\PackageWarning{hexboard}{command `hexletter' already defined}}
1385 \@ifundefined{hexsubrow}{}
1386 {\PackageWarning{hexboard}{command `hexsubrow' already defined}}
1387 \@ifundefined{hexskipmove}{}
1388 {\PackageWarning{hexboard}{command `hexskipmove' already defined}}
1389 \@ifundefined{hexmovenumber}{}
1390 {\PackageWarning{hexboard}{command `hexmovenumber' already defined}}
1391 \makeatother
1392
1393 \newcommand{\xchor}{0} % x-coordinate.
1394 \newcommand{\ychor}{0} % y-coordinate.
1395
1396 \newcommand{\colorA}{red}
1397 \newcommand{\colorB}{blue}
1398 \newcommand{\hexlinewidth}{0.07}
1399 \newcommand{\hexedgewidth}{0.15}
1400 \newcommand{\hexthinline}{0.03}
1401 \newcommand{\hexscale}[1]{
1402 \tikzset{hex/.style={scale=#1,every node/.style={scale=#1}}}
1403 \pgfmathsetmacro\hexlinewidth{#1 * 0.07}
1404 \pgfmathsetmacro\hexedgewidth{#1 * 0.15}
1405 \pgfmathsetmacro\hexthinline{#1 * 0.03}
1406 }
1407 \hexscale{2}
1408
1409 \newcommand{\setcolorA}[1]{\renewcommand{\colorA}{#1}}
1410 \newcommand{\setcolorB}[1]{\renewcommand{\colorB}{#1}}
1411
1412 %% This calculates the values of the hex coordinate grid.
1413 % xc = x + 0.5 y
1414 % yc = sqrt(3)/2*y
1415 \newcounter{hexletternum}
1416 \newcommand{\hexcoord}[2]{%
1417 \ifnum0<0#1\relax % is it a number?
1418 \pgfmathsetmacro\xchor{#1 + 0.5 * #2}
1419 \else % assume it's a letter
1420 \setcounter{hexletternum}{0}
1421 \foreach \hexletter in {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}{%
1422 \addtocounter{hexletternum}{1}
1423 \IfEq{\hexletter}{#1}{\breakforeach}{}
1424 }
1425 \pgfmathsetmacro\xchor{\value{hexletternum} + 0.5 * #2}
1426 \fi
1427 \pgfmathsetmacro\ychor{sqrt(3)/2 * #2}
1428 }
1429
1430 \pgfmathsetmacro\hexsize{2/sqrt(3)} % size of the node we want tikz to draw a hexagon inside
1431
1432 \newcommand{\hexcell}[2]{%
1433 \hexcoord{#1}{#2}
1434 \node[regular polygon,draw,regular polygon sides=6,rotate=90,line width=\hexlinewidth em,minimum size=\hexsize em] at (\xchor em,\ychor em) {};
1435 }
1436
1437 \newcommand{\hexcellshaded}[3][yellow]{%
1438 \hexcoord{#2}{#3}
1439 \node[regular polygon,draw,regular polygon sides=6,rotate=90,line width=\hexlinewidth em,minimum size=\hexsize em,fill=#1] at (\xchor em,\ychor em) {};
1440 }
1441
1442 % Place a counter in the spot.
1443 % Radius of the incircle of the hex is 0.5, so we make the radius a little smaller
1444 \newcommand{\thiscolor}{\colorB}
1445 \newcommand{\hexcounter}[3]{%
1446 \renewcommand{\thiscolor}{\colorB}
1447 \def\testA{A}
1448 \def\argiii{#3}
1449 \if\argiii\testA
1450 \renewcommand{\thiscolor}{\colorA}
1451 \fi
1452
1453 \hexcoord{#1}{#2}
1454 \draw[\thiscolor,fill=\thiscolor] (\xchor em,\ychor em) circle (0.35em);
1455 }
1456 \newcommand{\hexcounterlabel}[4]{%
1457 \hexcounter{#1}{#2}{#3}
1458 \hexcontent[white]{#1}{#2}{#4}
1459 }
1460
1461 \newcommand{\hexdot}[2]{%
1462 \hexcoord{#1}{#2}
1463 \draw[fill] (\xchor em,\ychor em) circle (0.1em);
1464 }
1465
1466 \newcommand{\hexcontent}[4][black]{%
1467 \hexcoord{#2}{#3}
1468 \node[text=#1] at (\xchor em,\ychor em) {{\sf\scriptsize #4}};
1469 }
1470
1471 % This shows a curved line through three hexes. PR I'm not sure this describes what the original did - no curve? And it goes from (#1,#2) to (#3,#4).
1472 % used to display bridges
1473 \newcommand{\hexconnect}[4]{%
1474 \hexcoord{#1}{#2}
1475 \node[minimum size=0,inner sep=0,outer sep=0] (A) at (\xchor em,\ychor em) {};
1476 \hexcoord{#3}{#4}
1477 \node[minimum size=0,inner sep=0,outer sep=0] (B) at (\xchor em,\ychor em) {};
1478 \draw[line width=\hexthinline em,line cap=round] (A) -- (B);
1479 }
1480
1481 \newcommand{\hexgridnolabel}[2]{
1482
1483 \foreach \Ia in {1,...,#1}{
1484 % Place the hex cells.
1485 \foreach \Ib in {1,...,#2}{
1486 \hexcell{\Ia}{\Ib}
1487 }
1488 }
1489 \ifnum#1<3 % don't loop
1490 \ifnum#1=2
1491 % Coloured boundary
1492 \hexcoord{1}{1}
1493 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (0 em,-0.577350 em) -- (0.5 em,-0.288675 em); % bottom edge
1494 \hexcoord{1}{#2}
1495 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,0.288675 em) -- (0 em,0.577350 em) -- (0.5 em,0.288675 em); % top edge
1496 % \else % 1, hopefully
1497 % % Coloured boundary
1498 % \hexcoord{1}{1}
1499 % \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (0 em,-0.577350 em) -- (0.5 em,-0.288675 em); % bottom edge
1500 % \hexcoord{1}{#2}
1501 % \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,0.288675 em) -- (0 em,0.577350 em) -- (0.5 em,0.288675 em); % top edge
1502 \fi
1503 \else
1504 \pgfmathsetmacro\Iaend{#1-1}
1505 \foreach \Ia in {2,...,\Iaend}{ % top to bottom player A
1506 % Coloured boundary
1507 \hexcoord{\Ia}{1}
1508 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (0 em,-0.577350 em) -- (0.5 em,-0.288675 em); % bottom edge
1509 \hexcoord{\Ia}{#2}
1510 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,0.288675 em) -- (0 em,0.577350 em) -- (0.5 em,0.288675 em); % top edge
1511 }
1512 \fi
1513
1514 % Awkward corners
1515
1516 \hexcoord{1}{#2}
1517 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=butt] (-0.25 em,0.4330125 em) -- (0 em,0.577350 em);
1518 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (0 em,0.577350 em) -- (0.5 em,0.288675 em); % top left colorA
1519
1520 \ifnum#1>1
1521 \hexcoord{#1}{#2}
1522 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=butt] (-0.5 em,0.288675 em) -- (0 em,0.577350 em) -- (0.5 em,0.288675 em); % top right colorA
1523 \hexcoord{1}{1}
1524 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (0 em,-0.577350 em) -- (0.5 em,-0.288675 em); % bottom left colorA
1525 \fi
1526
1527 \hexcoord{#1}{1}
1528 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (0 em,-0.577350 em); % top right colorA
1529 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=butt] (0.25 em,-0.4330125 em) -- (0 em,-0.577350 em); % awkward bit
1530
1531
1532 \ifnum#2<3 % don't loop
1533 \ifnum#2=2
1534 % Coloured boundary
1535 \hexcoord{1}{1}
1536 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (-0.5 em,0.288675 em) -- (0 em,0.577350 em); % left edge
1537 \hexcoord{#1}{2}
1538 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (0 em,-0.577350 em) -- (0.5 em,-0.288675 em) -- (0.5 em,0.288675 em); % right edge
1539 % \else % 1, hopefully
1540 % % Coloured boundary
1541 % \hexcoord{1}{1}
1542 % \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (0 em,-0.577350 em) -- (0.5 em,-0.288675 em); % bottom edge
1543 % \hexcoord{1}{#2}
1544 % \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,0.288675 em) -- (0 em,0.577350 em) -- (0.5 em,0.288675 em); % top edge
1545 \fi
1546 \else
1547 \pgfmathsetmacro\Iaend{#2-1}
1548 \foreach \Ia in {2,...,\Iaend}{ % left to right player B
1549 % Coloured boundary
1550 \hexcoord{1}{\Ia}
1551 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (-0.5 em,0.288675 em) -- (0 em,0.577350 em); % left edge
1552 \hexcoord{#1}{\Ia}
1553 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (0 em,-0.577350 em) -- (0.5 em,-0.288675 em) -- (0.5 em,0.288675 em); % right edge
1554 }
1555 \fi
1556
1557 % Awkward corners
1558 \hexcoord{#1}{1}
1559 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=butt] (0.25 em,-0.4330125 em) -- (0.5 em,-0.288675 em);
1560
1561 \ifnum#2>1
1562 \hexcoord{1}{1}
1563 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=] (-0.5 em,-0.288675 em) -- (-0.5 em,0.288675 em) -- (0 em,0.577350 em); % bottom left colorB
1564 \hexcoord{#1}{#2}
1565 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (0 em,-0.577350 em) -- (0.5 em,-0.288675 em) -- (0.5 em,0.288675 em); % top right colorB
1566 \fi
1567
1568 \hexcoord{#1}{1}
1569 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (0.5 em,-0.288675 em) -- (0.5 em,0.288675 em); % bottom right colorB
1570
1571 \hexcoord{1}{#2}
1572 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (-0.5 em,0.288675 em); % top left colorB
1573 \draw[\colorB,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=butt] (-0.25 em,0.4330125 em) -- (-0.5 em,0.288675 em); % awkward bit
1574 }
1575
1576 \newcommand{\hexreducingnoborder}[2]{
1577 % Place the hex cells.
1578 \foreach \Ib in {1,...,#2}{
1579 \pgfmathsetmacro\Iaend{#1+1-\Ib}
1580 \foreach \Ia in {1,...,\Iaend}{
1581 \hexcell{\Ia}{\Ib}
1582 }
1583
1584 }
1585 }
1586
1587 \newcommand{\hexbottomsubborder}[2]{%
1588 % Coloured boundary
1589
1590 % bottom edge
1591 \foreach \Ia in {#1,...,#2}{
1592 % Coloured boundary
1593 \hexcoord{\Ia}{1}
1594 \draw[\colorA,shift={(\xchor em,\ychor em)},line width=\hexedgewidth em,line cap=round] (-0.5 em,-0.288675 em) -- (0 em,-0.577350 em) -- (0.5 em,-0.288675 em); % bottom edge
1595 }
1596 }
1597
1598
1599 \newcommand{\hexreducing}[2]{
1600 % Place the hex cells.
1601 \hexreducingnoborder{#1}{#2}
1602
1603 % bottom edge
1604 \hexbottomsubborder{1}{#1}
1605 }
1606
1607 \newcommand{\hexsubrow}[3]{
1608 \foreach \Ia in {#1,...,#2}{\hexcell{\Ia}{#3}}
1609 }
1610
1611 \newcommand{\hexshadedsubrow}[3]{
1612 \foreach \Ia in {#1,...,#2}{\hexcellshaded{\Ia}{#3}}
1613 }
1614
1615 \newcounter{hexedge}
1616 \newcommand{\hexgrid}[2]{
1617 \hexgridnolabel{#1}{#2}
1618
1619 % labels
1620 \setcounter{hexedge}{0}
1621 \foreach \Ia in {1,...,#1}{
1622 \addtocounter{hexedge}{1}
1623 \pgfmathsetmacro\leftofIa{\Ia+0.1}
1624 \pgfmathsetmacro\belowIa{1-1/sqrt(3)-0.2}
1625 \ifnum\value{hexedge}<27
1626 \node[scale=0.3] at (\leftofIa em,\belowIa em) {{\sf\color{\colorA}\alph{hexedge}}};
1627 \else
1628 \node[scale=0.3] at (\leftofIa em,\belowIa em) {{\sf\color{\colorA}\arabic{hexedge}}};
1629 \fi
1630 }
1631 \setcounter{hexedge}{0}
1632 \foreach \Ia in {1,...,#2}{
1633 \addtocounter{hexedge}{1}
1634 \hexcoord{1}{\Ia}
1635 \pgfmathsetmacro\leftofxchor{\xchor-0.75}
1636 \node[scale=0.3] at (\leftofxchor em,\ychor em) {{\sf\color{\colorB}\arabic{hexedge}}};
1637 }
1638 }
1639
1640 \newcommand{\hexboard}[1]{
1641 \hexgrid{#1}{#1}
1642 }
1643
1644 \newenvironment{hexpicture}{\begin{tikzpicture}[hex]}{\end{tikzpicture}}
1645
1646 \newcounter{hexmovecount} % keep track of moves
1647 \newcounter{hexmoveskips} % count skipped moves
1648 \newcommand{\hexmovenumber}{0} % label of current move
1649
1650 \newcounter{hexlabelling}
1651 \newenvironment{hexgame}[1][11]{%
1652 \begin{hexpicture}
1653 \hexboard{#1}
1654 \setcounter{hexmovecount}{0}
1655 \setcounter{hexmoveskips}{0}
1656 \setcounter{hexlabelling}{0}}
1657 {\end{hexpicture}}
1658 \newenvironment{hexgamelabels}[1][11]{%
1659 \begin{hexgame}[#1]
1660 \setcounter{hexlabelling}{1}}
1661 {\end{hexgame}}
1662
1663
1664 \newcommand{\hexthismover}{B}
1665
1666 \newcommand{\hexmove}[2]{%
1667 \addtocounter{hexmovecount}{1}
1668 \renewcommand{\hexthismover}{B}
1669 \ifodd\value{hexmovecount}\renewcommand{\hexthismover}{A}\fi
1670
1671 \pgfmathtruncatemacro\hexmovenumber{\value{hexmovecount}-\value{hexmoveskips}} % move label is moves minus skips
1672 \ifnum\value{hexlabelling}=1\hexcounterlabel{#1}{#2}{\hexthismover}{\hexmovenumber}\else\hexcounter{#1}{#2}{\hexthismover}\fi
1673 }
1674
1675 \newcommand{\hexskipmove}{%
1676 \addtocounter{hexmovecount}{1}
1677 \addtocounter{hexmoveskips}{1}
1678 }
1679 %</hexboard>
1680 %\fi