AGAPO
Abstract Game PostScripts

by Cameron Browne and João Neto

The POSTSCRIPT page description language provides a device independent standard for representing the printed page. [...] The POSTSCRIPT language is a programming language designed to convey a description of virtually any desired page to a printer. It possesses a wide range of graphic operators that may be combined in any manner. It contains variables and allows the combining of operators into more complex procedures and functions. [cited from "Postscript - Tutorial and Cookbook" - Adobe Systems].

Herein we present agapo, a set of postscript examples to ease the task of drawing board game diagrams. You can download files for Go-like diagrams (also for hex boards), Othello-like diagrams, Hex-like diagrams, Checker-like diagrams (also for hex boards) , Mancala boards, Chess-like diagrams, Dominoes and Tesselations. These are text files (use your favorite text editor to open it). Each have two parts: (a)  a set of routines (learn how to use them in the next sections) that handle the drawings (do not modify them before you learn a bit of PostScript) and (b) an example that you should change in order to make your own diagrams.

Some PostScript interpreters may work better if the files end in .eps (Encapsulated PostScript) others with .ps. The internal code need not be changed.

Go-like diagrams

There are the following routines:

Board
Usage: rows cols [true|false] Board
makes a GO board with size (rows+1) x (cols+1) with/without coordinates
Example:
4 7 false Board

White
Usage: row col White
draws a white stone at position (row,col)
Example:
2 3 White

Black
Usage: row col Black
draws a black stone at position (row,col)
Example:
2 3 Black

Grey
Usage: row col Grey
draws a grey stone at position (row,col)
Example:
2 3 Grey

Marker
Usage: row col [0-1] (string) Marker
draws a string (usually one character) at a given position. The 3rd argument is the color (between 0=black and 1=white). The 4th argument defines two types of presentation.
Example:
5 4 1 false (a) Marker

MarkerSm
Usage: row col [0-1] (string) MarkerSm
draws a string (usually two characters) at a given position.
Example:
5 4 1 false (12) MarkerSm

WhiteSpot
Usage: row col WhiteSpot
draws a white spot at position (row,col)
Example:
1 4 WhiteSpot

BlackSpot
Usage: row col BlackSpot
draws a Black spot at position (row,col)
Example:
2 3 BlackSpot

This example produces this image:

6 10 true Board

6 4 White
3 5 White
4 4 White
6 5 White
7 5 White
3 6 White
5 2 Black
5 3 Black
3 4 Black
5 4 Black
2 5 Black
4 5 Black
2 7 Black 
1 1 Grey

5 4 1 false (12) MarkerSm
5 3 1 false (b) Marker
4 4 0 true (c) Marker
6 2 WhiteSpot
6 2 0 false (d) Marker
3 3 BlackSpot

There are also the possibility of Rosette-like games (however, the labels are not automatic). This file does not have an automatic board routine. You'll need to place each hexagon. The coordinates are not orthogonal: changing x and maintaining y will produce a diagonal line of hexagons. There is also a 3rd coordinate z which places the stone at a vertex of that hex (0 is the top left vertex, and it goes clockwise, check the example). This is the diagram produced by rosette-template.eps:.

Othello-like diagrams

The methods are the same as in the previous section (except WhiteSpot and BlackSpot), including:

White2
Usage: row col White2
draws a second type of white stone at position (row,col)
Example:
2 3 White2

Black2
Usage: row col Black2
draws a second type of black stone at position (row,col)
Example:
2 3 Black2

6 6 true Board

6 4 White
3 5 White2
6 5 White
3 6 White

5 2 Black
3 4 Black
5 4 Black
2 5 Black2 

2 1 Grey

5 2 1 true (a) Marker
6 5 0 false (12) MarkerSm
4 4 0 true (c) Marker
6 2 0 false (d) Marker

Hex-like diagrams

Includes routines White, Black, Black2, Grey, Marker, MarkerSm and:

Hexagon
Usage: x y Hexagon
draws a hexagon at position (x,y)
Example:
2 3 Hexagon

Label
Usage: x y (string) Label
draws a string at position (x,y)
Example:
2 3 Label

This file does not have an automatic board routine. You'll need to place each hexagon. The coordinates are not orthogonal: changing x and maintaining y will produce a diagonal line of hexagons. This is the diagram produced by hex-template.eps:

Checker-like diagrams

Includes routines Marker, MarkerSm and:

Board
Usage: rows cols int-array [insert coordinates?] Board
The array presents all pieces onboard. Each cell have a number up to 5 digits that define the stack's structure.
1 is a white checker, 2 a black checker, 3 a grey checker; 4,5,6: white,black,grey stones with dots.

White
Usage: row col height White
draws a white stone at position (row,col) with a certain height 
Example:
2 3 2 White

Black
Usage: row col height Black
draws a black stone at position (row,col) with a certain height 
Example:
2 3 0 Black

Grey
Usage: row col height Grey
draws a grey stone at position (row,col) with a certain height 
Example:
2 3 1 Grey

There is also WhiteDot, BlackDot, GreyDot with the same arguments, but place a checker with a dot.

8 8 [ 0    0     0   0   0   0   0   0
      0    0     0   0   0   0   0   0
      0    0     0   0   0   0   0   0
  23456    0     0   0   0   0   0   0
      0    0     0   0   0   0   0   0
   1111 1231 13121 423 141 252 363 456
     23   33   112 123 321 222 123 232
      1    2     3  11  12  13  21  22
  ] true Board y

There is also another file for checker like pieces in hex boards:

Mancala diagrams

There are the following routines:

Board
Usage: rows cols [boolean coord] [boolean houses] Board
makes a Mancala board with size rows x cols with/without coordinates and with/without houses
Example:
2 6 false true Board

White1
Usage: row col White1
draws one white stone at position (row,col)
Example:
2 3 White1

Black1
Usage: row col Black
draws one black stone at position (row,col)
Example:
2 3 Black1

Similar functions: Black2, Black3, Black4, Black5, Black6 (and also White2 to White6) which places from 2 to 6 stones at a given cell. There is also Blacks (and Whites) to be used for cells with more than 6 stones. These last functions should be used with:

Marker
Usage: row col [0-1] (string) Marker
draws a string (usually one character) at a given position. The 3rd argument is the color (in this case, is better to use color 0)
Example:
5 4 0 (7) Marker

MarkerSm
Usage: row col [0-1]  (string) MarkerSm
draws a string (usually two characters) at a given position. The 3rd argument is the color (in this case, is better to use color 0).
Example:
5 4 0 (12) MarkerSm

2 6 false false Board 

1 1 Black4
1 2 Black4
1 3 Black4
1 4 Black4
1 5 Black4
1 6 Black4

2 1 Black4
2 2 Black4
2 3 Black4
2 4 Black4
2 5 Black4
2 6 Black4

3 7 true true Board

2 3 White1
2 4 Black1
2 5 Black2 
1 2 Black3
1 4 Black4
1 6 Black5
2 6 Black6

3 6 Blacks
3 7 Blacks

3 6 0 (7) Marker
3 7 0 (13) MarkerSm

Chess diagrams

This postscript needs this font (on Windows you may need to put it on folder \Windows\Fonts).

There are the following routines: Board, Marker, MarkerSm

Board
Usage: rows cols int-array [insert coordinates?] Board
The array presents all pieces onboard. 1,2,3,4,5,6 means white pawn, knight, bishop, rook, queen and King. A minus signal on those numbers represent black pieces. Add 10 to invert white pieces, subtract 10 to invert black pieces.

8 8 [ -4 -2 -3 -5 -6 -3 -2 -4
      -1 -1 -1 -1 -1 -1 -1 -1
       0  0  0  0  0  0  0  0
       0  0  0  0  0  0  0  0
       0  0  0  0  0  0  0  0
       0  0  0  0  0  0  0  0
       1  1  1  1  1  1  1  1
       4 12  3  5  6  3  2  4 ] true Board
 

Dominoes diagrams

There are the following routines: DominoUp, DominoRight, Sq

DominoUp & DominoRight
Usage: rows cols dot-number1 dot-number-2 Domino[Up/Right]

Sq
Usage: rows cols north-bold-line? east-bold-line? south-bold-line? west-bold-line? dot-number Sq

If the dot-number is negative, it rotates 90º.

Here is an example using dominoes-template.eps:

 7 0 4 2 DominoRight
 7 2 2 3 DominoRight
 6.5 4 3 3 DominoUp
 7 5 3 6 DominoRight

 5.5 1.5 false false true true 2 Sq

Tesselations

Polygon
Usage: xx yy rotation n-sides Polygon
draws a polygon at (x,y) with n sides and a certain rotation (between 0-359)
Example:
1 0 TriXY 0 3 Polygon

There are a set of routines that help to pinpoint the exact position for each polygon (Hex, Tri, Square, Octo, Dode). Check the source file to see how the following examples are designed: