-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhexboard.dtx
1680 lines (1634 loc) · 47.3 KB
/
hexboard.dtx
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
%\iffalse meta-comment
%Copyright (c) 2022 Peter Rowlett and Chris Sangwin
%
%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/
%\fi
%\title{\textsf{hexboard} v1.0}
%\author{Peter Rowlett and Chris Sangwin}
%\maketitle
%
%\begin{center}
% \hexscale{3}
% \begin{hexgame}[4]
% \hexcellshaded{b}{3}
% \hexmove{b}{2}
% \hexmove{b}{1}
% \hexmove{c}{1}
% \hexmove{d}{1}
% \hexmove{a}{2}
% \hexmove{b}{3}
% \hexmove{b}{4}
% \hexmove{c}{3}
% \hexmove{d}{3}
% \hexdot{a}{4}
% \hexdot{a}{3}
% \hexconnect{b}{3}{a}{3}
% \hexconnect{b}{3}{a}{4}
% \hexcontent{d}{2}{\(\star\)}
% \end{hexgame}
% \hexscale{2}
%\end{center}
%
%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/}
%
%\tableofcontents
%
%\section{Background}
%
%\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.
%
%\section{Usage notes}
%
%\subsection{The game Hex}
%
%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).
%
%\subsection{hexpicture}
%
%Hex boards are drawn inside an environment called \verb|hexpicture|. The basic structure for drawing with this package is
%
%\begin{verbatim}\begin{hexpicture}
%...
%\end{hexpicture}\end{verbatim}
%
%\subsection{Coordinate labels}
%
%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.
%
%\begin{verbatim}\hexmove{d}{1}
%\hexmove{4}{1}\end{verbatim}
%
%In this document, letters are used to match the board labels.
%
%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.
%
%\subsection{Order of commands}
%
%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.
%
%For example, it is best to draw shaded cells early so that they appear behind other elements. For example, the counter is hidden here:
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{4}
%\hexcounter{b}{2}{B}
%\hexcellshaded{b}{2}
%\hexcellshaded{c}{3}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{4}
% \hexcounter{b}{2}{B}
% \hexcellshaded{b}{2}
% \hexcellshaded{c}{3}
%\end{hexpicture}
%
%Whereas the hidden counter appears if the commands are reordered:
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{4}
%\hexcellshaded{b}{2}
%\hexcellshaded{c}{3}
%\hexcounter{b}{2}{B}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{4}
% \hexcellshaded{b}{2}
% \hexcellshaded{c}{3}
% \hexcounter{b}{2}{B}
%\end{hexpicture}
%
%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.)
%
%For example, if this happens:
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{5}
%\hexshadedsubrow{b}{e}{1}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{5}
% \hexshadedsubrow{b}{e}{1}
%\end{hexpicture}
%
%try this instead:
%
%\begin{verbatim}\begin{hexpicture}
%\hexshadedsubrow{b}{e}{1}
%\hexboard{5}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexshadedsubrow{b}{e}{1}
% \hexboard{5}
%\end{hexpicture}
%
%
%\section{Basic usage}
%
%\subsection{Drawing Hex boards}
%
%The basic usage is via \verb|\hexboard{num}| which draws a Hex board of size \verb|num| by \verb|num|. For example, the command
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{11}
%\end{hexpicture}\end{verbatim}
%
%Produces a Hex board like this\\
%
%\begin{hexpicture}
% \hexboard{11}
%\end{hexpicture}
%
%\subsection{Drawing Hex games}
%
%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.
%
%An optional parameter controls the size of the board, with default 11.
%
%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.
%
%For example, here is a Hex game on a 4 by 4 board without labelling using \verb|hexgame|:
%
%\begin{verbatim}\begin{hexgame}[4]
%\hexmove{a}{2}
%\hexmove{c}{3}
%\hexmove{b}{2}
%\hexmove{c}{2}
%\hexmove{c}{1}
%\hexmove{d}{1}
%\hexmove{b}{3}
%\hexmove{b}{4}
%\hexmove{a}{4}
%\end{hexgame}\end{verbatim}
%
%\begin{hexgame}[4]
% \hexmove{a}{2}
% \hexmove{c}{3}
% \hexmove{b}{2}
% \hexmove{c}{2}
% \hexmove{c}{1}
% \hexmove{d}{1}
% \hexmove{b}{3}
% \hexmove{b}{4}
% \hexmove{a}{4}
%\end{hexgame}
%
%Here is a Hex game on a 5 by 5 board with move labelling using \verb|hexgamelabels|:
%
%\begin{verbatim}\begin{hexgamelabels}[5]
%\hexmove{c}{2}
%\hexmove{b}{4}
%\hexmove{b}{3}
%\hexmove{d}{3}
%\hexmove{a}{5}
%\hexmove{a}{4}
%\hexmove{c}{3}
%\hexmove{c}{4}
%\hexmove{e}{3}
%\hexmove{e}{2}
%\end{hexgamelabels}\end{verbatim}
%
%\begin{hexgamelabels}[5]
% \hexmove{c}{2}
% \hexmove{b}{4}
% \hexmove{b}{3}
% \hexmove{d}{3}
% \hexmove{a}{5}
% \hexmove{a}{4}
% \hexmove{c}{3}
% \hexmove{c}{4}
% \hexmove{e}{3}
% \hexmove{e}{2}
%\end{hexgamelabels}
%
%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).
%
%\begin{verbatim}\begin{hexgamelabels}[4]
%\hexskipmove
%\hexmove{b}{3}
%\hexmove{c}{3}
%\hexmove{c}{2}
%\end{hexgamelabels}\end{verbatim}
%
%\begin{hexgamelabels}[4]
% \hexskipmove
% \hexmove{b}{3}
% \hexmove{c}{3}
% \hexmove{c}{2}
%\end{hexgamelabels}
%
%\subsection{Placing Hex counters}
%
%Within a \verb|hexpicture|, individual counters can be placed using \verb|\hexcounter{x}{y}{player}|.
%
%For example,
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{5}
%\hexcounter{b}{1}{B}
%\hexcounter{c}{2}{B}
%\hexcounter{d}{2}{B}
%\hexcounter{c}{1}{A}
%\hexcounter{e}{1}{A}
%\hexcounter{c}{3}{A}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{5}
% \hexcounter{b}{1}{B}
% \hexcounter{c}{2}{B}
% \hexcounter{d}{2}{B}
% \hexcounter{c}{1}{A}
% \hexcounter{e}{1}{A}
% \hexcounter{c}{3}{A}
%\end{hexpicture}
%
%\subsection{Drawing a shaded cell}
%
%The command \verb|\hexcellshaded{x}{y}| is used to draw a shaded cell.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{4}
%\hexcellshaded{b}{2}
%\hexcellshaded{c}{3}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{4}
% \hexcellshaded{b}{2}
% \hexcellshaded{c}{3}
%\end{hexpicture}
%
%The default shading colour is yellow. An optional parameter allows you to change this. For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{4}
%\hexcellshaded{b}{2}
%\hexcellshaded{c}{3}
%\hexcellshaded[magenta]{c}{2}
%\hexcellshaded[lime]{b}{3}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{4}
% \hexcellshaded{b}{2}
% \hexcellshaded{c}{3}
% \hexcellshaded[magenta]{c}{2}
% \hexcellshaded[lime]{b}{3}
%\end{hexpicture}
%
%\subsection{Drawing a small dot}
%
%To indicate a position on the board using a small dot, use \verb|\hexdot{x}{y}|.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{4}
%\hexdot{b}{2}
%\hexdot{c}{3}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{4}
% \hexdot{b}{2}
% \hexdot{c}{3}
%\end{hexpicture}
%
%\subsection{Drawing lines}
%
%The command \verb|\hexconnect{x1}{y1}{x2}{y2}| draws a line from cell (\verb|x1|,\verb|y1|) to cell (\verb|x2|,\verb|y2|).
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{3}
%\hexcounter{b}{1}{A}
%\hexconnect{b}{1}{b}{2}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{3}
% \hexcounter{b}{1}{A}
% \hexconnect{b}{1}{b}{2}
%\end{hexpicture}
%
%\subsection{Putting text or other content in a cell}
%
%The command \verb|\hexcontent{x}{y}{content}| puts \verb|content| into cell (\verb|x|,\verb|y|).
%
%For example, here we write ``b2'' in cell b2.
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{3}
%\hexcontent{b}{2}{b2}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{3}
% \hexcontent{b}{2}{b2}
%\end{hexpicture}
%
%By default, the text is \verb|\scriptsize| (and then scaled by \verb|\hexscale|, see \ref{scaling}). This can be overridden.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{3}
%\hexcontent{b}{2}{\tiny here}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{3}
% \hexcontent{b}{2}{\tiny here}
%\end{hexpicture}
%
%The \verb|content| can contain other \LaTeX\ commands. For example
%
%\begin{verbatim}\usepackage{rotating}
%...
%\begin{hexpicture}
%\hexboard{9}
%\hexcontent{e}{5}{\begin{turn}{30}
%\colorbox{lightgray}{\color{blue}{\normalsize \textbf{Fancy a game?}}}
%\end{turn}}
%\end{hexpicture}\end{verbatim}
%
%
%\begin{hexpicture}
% \hexboard{9}
% \hexcontent{e}{5}{\begin{turn}{30}
% \colorbox{lightgray}{\color{blue}{\normalsize \textbf{Fancy a game?}}}
% \end{turn}}
%\end{hexpicture}
%
%\section{User configuration}
%
%\subsection{Scaling images}\label{scaling}
%
%The basic unit of the diagrams can be scaled using \verb|\hexscale{number}|. The default is 2.
%
%For example \verb|\hexscale{8}| changes this\\
%
%\begin{hexpicture}
% \hexcell{a}{1}
% \hexcellshaded{b}{1}
% \hexcellshaded{a}{2}
% \hexcell{b}{2}
% \hexcounter{a}{1}{A}
% \hexcounter{b}{2}{A}
% \hexdot{a}{2}
% \hexdot{b}{1}
% \hexconnect{a}{1}{a}{2}
% \hexconnect{a}{1}{b}{1}
% \hexconnect{a}{2}{b}{2}
% \hexconnect{b}{1}{b}{2}
%\end{hexpicture}
%
%into this\\
%
%\hexscale{8}
%\begin{hexpicture}
% \hexcell{a}{1}
% \hexcellshaded{b}{1}
% \hexcellshaded{a}{2}
% \hexcell{b}{2}
% \hexcounter{a}{1}{A}
% \hexcounter{b}{2}{A}
% \hexdot{a}{2}
% \hexdot{b}{1}
% \hexconnect{a}{1}{a}{2}
% \hexconnect{a}{1}{b}{1}
% \hexconnect{a}{2}{b}{2}
% \hexconnect{b}{1}{b}{2}
%\end{hexpicture}\\
%
%Fractional values are possible. For example
%
%\begin{verbatim}\hexscale{0.5}
%\begin{hexpicture}
%\hexboard{2}
%\hexcounter{a}{1}{A}
%\hexcounter{b}{2}{B}
%\end{hexpicture}\end{verbatim}
%
%\hexscale{0.5}
%\begin{hexpicture}
% \hexboard{2}
% \hexcounter{a}{1}{A}
% \hexcounter{b}{2}{B}
%\end{hexpicture}
%
%and
%
%\begin{verbatim}\hexscale{3.5}
%\begin{hexpicture}
%\hexboard{2}
%\hexcounter{a}{1}{A}
%\hexcounter{b}{2}{B}
%\end{hexpicture}\end{verbatim}
%
%\hexscale{3.5}
%\begin{hexpicture}
% \hexboard{2}
% \hexcounter{a}{1}{A}
% \hexcounter{b}{2}{B}
%\end{hexpicture}
%
%\hexscale{2}
%
%\subsection{Colours}
%
%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.
%
%For example, for a greyscale diagram use
%
%\begin{verbatim}\setcolorA{lightgray}
%\setcolorB{darkgray}\end{verbatim}
%
%This changes this\\
%
%\begin{hexpicture}
% \hexboard{3}
% \hexcounter{a}{2}{B}
% \hexcounter{b}{3}{B}
% \hexcounter{c}{3}{A}
%\end{hexpicture}
%
%into this\\
%
%\setcolorA{lightgray}
%\setcolorB{darkgray}
%\begin{hexpicture}
% \hexboard{3}
% \hexcounter{a}{2}{B}
% \hexcounter{b}{3}{B}
% \hexcounter{c}{3}{A}
%\end{hexpicture}
%\setcolorA{red}
%\setcolorB{blue}
%
%To use the current user colours elsewhere in the document, access these as \verb|\colorA| and \verb|\colorB|. For example
%
%\begin{verbatim}
%{\color{\colorA} This text is player A's colour} and
%{\color{\colorB} This text is player B's colour}.
%
%\setcolorA{teal}
%\setcolorB{magenta}
%{\color{\colorA} This text is player A's colour} and
%{\color{\colorB} This text is player B's colour}.
%\end{verbatim}
%
%{\color{\colorA} This text is player A's colour} and
%{\color{\colorB} This text is player B's colour}.
%
%\setcolorA{teal}
%\setcolorB{magenta}
%{\color{\colorA} This text is player A's colour} and
%{\color{\colorB} This text is player B's colour}.
%\setcolorA{red}
%\setcolorB{blue}
%
%
%\section{Advanced use}
%
%\subsection{Drawing an irregular board}
%
%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|.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexgrid{9}{5}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexgrid{9}{5}
%\end{hexpicture}
%
%\subsection{Drawing a board with no edge labels}
%
%The command \verb|\hexgridnolabel{columns}{rows}| is used to draw a grid of that size without edge labels.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexgridnolabel{9}{5}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexgridnolabel{9}{5}
%\end{hexpicture}
%
%
%\subsection{Drawing a single cell}
%
%An individual cell is drawn using \verb|\hexcell{x}{y}|.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexcell{a}{1}
%\hexcell{b}{1}
%\hexcell{b}{2}
%\hexcell{c}{4}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexcell{a}{1}
% \hexcell{b}{1}
% \hexcell{b}{2}
% \hexcell{c}{4}
%\end{hexpicture}
%
%\subsection{Drawing a sub-row}
%
%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|.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexsubrow{b}{f}{1}
%\hexsubrow{a}{e}{2}
%\hexsubrow{a}{b}{3}
%\hexsubrow{d}{e}{3}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexsubrow{b}{f}{1}
% \hexsubrow{a}{e}{2}
% \hexsubrow{a}{b}{3}
% \hexsubrow{d}{e}{3}
%\end{hexpicture}
%
%\subsection{Shading a sub-row}
%
%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|.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexgrid{6}{4}
%\hexshadedsubrow{b}{d}{2}
%\hexshadedsubrow{c}{e}{3}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexgrid{6}{4}
% \hexshadedsubrow{b}{d}{2}
% \hexshadedsubrow{c}{e}{3}
%\end{hexpicture}
%
%\subsection{Drawing a partial bottom border}
%
%The command \verb|\hexbottomsubborder{start}{end}| draws a bottom border from column \verb|start| to column \verb|end|.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexsubrow{b}{f}{1}
%\hexsubrow{a}{e}{2}
%\hexsubrow{a}{d}{3}
%\hexbottomsubborder{b}{f}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexsubrow{b}{f}{1}
% \hexsubrow{a}{e}{2}
% \hexsubrow{a}{d}{3}
% \hexbottomsubborder{b}{f}
%\end{hexpicture}
%
%\subsection{Drawing a reducing part-board}
%
%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.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexreducing{6}{3}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexreducing{6}{3}
%\end{hexpicture}
%
%You can also draw a reducing board without a bottom coloured border using\\
%\verb|\hexreducingnoborder{columns}{rows}|.
%
%For example
%
%\begin{verbatim}\begin{hexpicture}
%\hexreducingnoborder{5}{4}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexreducingnoborder{5}{4}
%\end{hexpicture}
%
%\subsection{A note about board size}
%
%A 1 by 1 Hex board is possible.
%
%\begin{verbatim}\begin{hexpicture}
%\hexboard{1}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexboard{1}
%\end{hexpicture}\\
%
%By extension, irregular boards which are a single column or row are possible.
%
%\begin{verbatim}\begin{hexpicture}
%\hexgrid{1}{4}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexgrid{1}{4}
%\end{hexpicture}
%
%\begin{verbatim}\begin{hexpicture}
%\hexgrid{7}{1}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexgrid{7}{1}
%\end{hexpicture}
%
%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.
%
%For example
%
%\begin{verbatim}\hexscale{1.4}
%\begin{hexpicture}
%\hexgrid{27}{4}
%\hexcounter{z}{4}{A}
%\hexcounter{27}{4}{B}
%\end{hexpicture}\end{verbatim}
%
%\hexscale{1.4}
%\begin{hexpicture}
% \hexgrid{27}{4}
% \hexcounter{z}{4}{A}
% \hexcounter{27}{4}{B}
%\end{hexpicture}
%
%\hexscale{2}
%
%\subsection{Use with tikz}
%
%The package uses tikz and \verb|\usetikzlibrary{shapes.geometric}|. The definition of \verb|hexpicture| (also used by \verb|hexgame|) is
%
%\verb|\newenvironment{hexpicture}{\begin{tikzpicture}[hex]}{\end{tikzpicture}}|
%
%In theory, then, any tikz commands that will work in this context can be used.
%
%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.
%
%\begin{verbatim}\begin{hexpicture}
%\hexshadedsubrow{b}{h}{1}
%\hexshadedsubrow{b}{g}{2}
%\hexshadedsubrow{b}{f}{3}
%\hexshadedsubrow{c}{d}{4}
%\hexreducing{9}{5}
%\hexcounter{c}{4}{A}
%\hexdot{c}{3}
%\hexdot{e}{3}
%\hexconnect{c}{4}{c}{3}
%\hexconnect{c}{4}{d}{3}
%\hexconnect{d}{3}{e}{3}
%\hexconnect{c}{4}{d}{4}
%\hexconnect{d}{4}{e}{3}
%\hexcontent{e}{1}{?}
%\node at (14em,3em) {\parbox{5em}{\tiny Consider what happens if blue puts a
%piece in the hex marked ``?''.}};
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexshadedsubrow{b}{h}{1}
% \hexshadedsubrow{b}{g}{2}
% \hexshadedsubrow{b}{f}{3}
% \hexshadedsubrow{c}{d}{4}
% \hexreducing{9}{5}
% \hexcounter{c}{4}{A}
% \hexdot{c}{3}
% \hexdot{e}{3}
% \hexconnect{c}{4}{c}{3}
% \hexconnect{c}{4}{d}{3}
% \hexconnect{d}{3}{e}{3}
% \hexconnect{c}{4}{d}{4}
% \hexconnect{d}{4}{e}{3}
% \hexcontent{e}{1}{?}
% \node at (14em,3em) {\parbox{5em}{\tiny Consider what happens if blue puts a piece in the hex marked ``?''.}};
%\end{hexpicture}\\
%
%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.
%
%So if you for some reason wanted a pinkish-purple box aligned with certain cells of your Hex grid, you could do this.
%
%\begin{verbatim}\definecolor{lavendermist}{rgb}{0.9, 0.9, 0.98}
%\definecolor{lavenderpink}{rgb}{0.98, 0.68, 0.82}
%\definecolor{lavenderpurple}{rgb}{0.59, 0.48, 0.71}
%\begin{hexpicture}
%\hexboard{5}
%\hexcoord{c}{2}
%\node (n1) at (\xchor em,\ychor em) {};
%\hexcoord{d}{4}
%\node (n2) at (\xchor em,\ychor em) {};
%\draw[ultra thick,lavenderpink,left color=lavenderpurple,right
%color=lavendermist] (n1) rectangle (n2);
%\end{hexpicture}\end{verbatim}
%
%\definecolor{lavendermist}{rgb}{0.9, 0.9, 0.98}
%\definecolor{lavenderpink}{rgb}{0.98, 0.68, 0.82}
%\definecolor{lavenderpurple}{rgb}{0.59, 0.48, 0.71}
%\begin{hexpicture}
% \hexboard{5}
% \hexcoord{c}{2}
% \node (n1) at (\xchor em,\ychor em) {};
% \hexcoord{d}{4}
% \node (n2) at (\xchor em,\ychor em) {};
% \draw[ultra thick,lavenderpink,left color=lavenderpurple,right color=lavendermist] (n1) rectangle (n2);
%\end{hexpicture}
%
%\subsection{Internal}
%
%Various internal commands are used:
%
%\verb|hexedge| (counter)
%
%\verb|hexmovecount| (counter)
%
%\verb|\xchor|
%
%\verb|\ychor|
%
%\verb|\colorA|
%
%\verb|\colorB|
%
%\verb|\hexlinewidth|
%
%\verb|\hexedgewidth|
%
%\verb|\hexthinline|
%
%\verb|\hexcoord|
%
%\verb|\hexsize|
%
%\verb|\Ia|
%
%\verb|\Ib|
%
%\verb|\Iaend|
%
%\verb|\leftofIa|
%
%\verb|\belowIa|
%
%\verb|\leftofxchor|
%
%\section{Some examples}
%
%\begin{verbatim}\begin{hexpicture}
%\hexcell{a}{1}
%\hexcellshaded{b}{1}
%\hexcellshaded{a}{2}
%\hexcell{b}{2}
%\hexcounter{a}{1}{A}
%\hexcounter{b}{2}{A}
%\hexdot{a}{2}
%\hexdot{b}{1}
%\hexconnect{a}{1}{a}{2}
%\hexconnect{a}{1}{b}{1}
%\hexconnect{a}{2}{b}{2}
%\hexconnect{b}{1}{b}{2}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexcell{a}{1}
% \hexcellshaded{b}{1}
% \hexcellshaded{a}{2}
% \hexcell{b}{2}
% \hexcounter{a}{1}{A}
% \hexcounter{b}{2}{A}
% \hexdot{a}{2}
% \hexdot{b}{1}
% \hexconnect{a}{1}{a}{2}
% \hexconnect{a}{1}{b}{1}
% \hexconnect{a}{2}{b}{2}
% \hexconnect{b}{1}{b}{2}
%\end{hexpicture}
%
%\begin{verbatim}\begin{hexpicture}
%\hexshadedsubrow{b}{c}{1}
%\hexreducing{4}{2}
%\hexcounter{b}{2}{A}
%\hexdot{b}{1}
%\hexdot{c}{1}
%\hexconnect{b}{2}{b}{1}
%\hexconnect{b}{2}{c}{1}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexshadedsubrow{b}{c}{1}
% \hexreducing{4}{2}
% \hexcounter{b}{2}{A}
% \hexdot{b}{1}
% \hexdot{c}{1}
% \hexconnect{b}{2}{b}{1}
% \hexconnect{b}{2}{c}{1}
%\end{hexpicture}
%
%\begin{verbatim}\begin{hexpicture}
%\hexshadedsubrow{b}{e}{1}
%\hexshadedsubrow{b}{d}{2}
%\hexshadedsubrow{b}{c}{3}
%\hexreducing{6}{4}
%\hexcounter{b}{3}{A}
%\hexdot{b}{2}
%\hexdot{d}{2}
%\hexconnect{b}{3}{b}{2}
%\hexconnect{b}{3}{c}{2}
%\hexconnect{c}{2}{d}{2}
%\hexconnect{b}{3}{c}{3}
%\hexconnect{c}{3}{d}{2}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexshadedsubrow{b}{e}{1}
% \hexshadedsubrow{b}{d}{2}
% \hexshadedsubrow{b}{c}{3}
% \hexreducing{6}{4}
% \hexcounter{b}{3}{A}
% \hexdot{b}{2}
% \hexdot{d}{2}
% \hexconnect{b}{3}{b}{2}
% \hexconnect{b}{3}{c}{2}
% \hexconnect{c}{2}{d}{2}
% \hexconnect{b}{3}{c}{3}
% \hexconnect{c}{3}{d}{2}
%\end{hexpicture}
%
%
%\begin{verbatim}\begin{hexpicture}
%\hexshadedsubrow{b}{c}{1}
%\hexshadedsubrow{e}{f}{1}
%\hexshadedsubrow{b}{e}{2}
%\hexshadedsubrow{b}{d}{3}
%\hexreducing{7}{4}
%\hexcounter{c}{3}{A}
%\hexdot{b}{2}
%\hexdot{e}{2}
%\hexconnect{b}{2}{c}{2}
%\hexconnect{b}{3}{b}{2}
%\hexconnect{c}{3}{b}{3}
%\hexconnect{c}{3}{c}{2}
%\hexconnect{c}{3}{d}{2}
%\hexconnect{d}{2}{e}{2}
%\hexconnect{c}{3}{d}{3}
%\hexconnect{d}{3}{e}{2}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexshadedsubrow{b}{c}{1}
% \hexshadedsubrow{e}{f}{1}
% \hexshadedsubrow{b}{e}{2}
% \hexshadedsubrow{b}{d}{3}
% \hexreducing{7}{4}
% \hexcounter{c}{3}{A}
% \hexdot{b}{2}
% \hexdot{e}{2}
% \hexconnect{b}{2}{c}{2}
% \hexconnect{b}{3}{b}{2}
% \hexconnect{c}{3}{b}{3}
% \hexconnect{c}{3}{c}{2}
% \hexconnect{c}{3}{d}{2}
% \hexconnect{d}{2}{e}{2}
% \hexconnect{c}{3}{d}{3}
% \hexconnect{d}{3}{e}{2}
%\end{hexpicture}
%
%\begin{verbatim}\begin{hexpicture}
%\hexshadedsubrow{b}{i}{1}
%\hexshadedsubrow{b}{d}{2}
%\hexshadedsubrow{f}{h}{2}
%\hexshadedsubrow{b}{g}{3}
%\hexshadedsubrow{c}{e}{4}
%\hexreducing{10}{5}
%\hexcounter{d}{4}{A}
%\hexdot{c}{3}
%\hexdot{f}{3}
%\hexconnect{c}{3}{d}{3}
%\hexconnect{c}{4}{c}{3}
%\hexconnect{d}{4}{c}{4}
%\hexconnect{d}{4}{d}{3}
%\hexconnect{d}{4}{e}{3}
%\hexconnect{e}{3}{f}{3}
%\hexconnect{d}{4}{e}{4}
%\hexconnect{e}{4}{f}{3}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexshadedsubrow{b}{i}{1}
% \hexshadedsubrow{b}{d}{2}
% \hexshadedsubrow{f}{h}{2}
% \hexshadedsubrow{b}{g}{3}
% \hexshadedsubrow{c}{e}{4}
% \hexreducing{10}{5}
% \hexcounter{d}{4}{A}
% \hexdot{c}{3}
% \hexdot{f}{3}
% \hexconnect{c}{3}{d}{3}
% \hexconnect{c}{4}{c}{3}
% \hexconnect{d}{4}{c}{4}
% \hexconnect{d}{4}{d}{3}
% \hexconnect{d}{4}{e}{3}
% \hexconnect{e}{3}{f}{3}
% \hexconnect{d}{4}{e}{4}
% \hexconnect{e}{4}{f}{3}
%\end{hexpicture}
%
%\begin{verbatim}\begin{hexpicture}
%\hexsubrow{b}{f}{1}
%\hexsubrow{a}{e}{2}
%\hexsubrow{a}{d}{3}
%\hexsubrow{a}{c}{4}
%\hexshadedsubrow{c}{e}{1}
%\hexshadedsubrow{b}{d}{2}
%\hexshadedsubrow{b}{c}{3}
%\hexbottomsubborder{b}{f}
%\hexcounter{b}{3}{A}
%\hexcounter{c}{3}{A}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexsubrow{b}{f}{1}
% \hexsubrow{a}{e}{2}
% \hexsubrow{a}{d}{3}
% \hexsubrow{a}{c}{4}
% \hexshadedsubrow{c}{e}{1}
% \hexshadedsubrow{b}{d}{2}
% \hexshadedsubrow{b}{c}{3}
% \hexbottomsubborder{b}{f}
% \hexcounter{b}{3}{A}
% \hexcounter{c}{3}{A}
%\end{hexpicture}
%
%\begin{verbatim}\begin{hexpicture}
%\hexsubrow{b}{g}{1}
%\hexsubrow{b}{f}{2}
%\hexsubrow{a}{e}{3}
%\hexsubrow{a}{d}{4}
%\hexshadedsubrow{c}{f}{1}
%\hexshadedsubrow{c}{e}{2}
%\hexshadedsubrow{b}{d}{3}
%\hexshadedsubrow{b}{c}{4}
%\hexbottomsubborder{b}{g}
%\hexcounter{b}{4}{A}
%\hexcounter{c}{4}{A}
%\end{hexpicture}\end{verbatim}
%
%\begin{hexpicture}
% \hexsubrow{b}{g}{1}