Check out Grant Acedrex, our featured variant for April, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

New Grand Apothecary Chess Error.[Subject Thread] [Add Response]
H. G. Muller wrote on Thu, May 12, 2022 09:43 AM UTC in reply to Aurelian Florea from 08:46 AM:

To add a new piece (say X / x)  to the GAME-code generated by the Play-Test applet you would have to add its move definitions at the end of the legdefs array, and supply functions X and x that return where in the legdefs array you have done that. Determining the latter is a bit of a pain; there are comments in the legdefs table that in parentheses indicate where the definition for each piece type starts, and you can then count the numbers appearing after that. Note that because the 'bare Pawn' is an asymmetric piece you would need different definitions for the white and the black one.

The move definition of a (white) FIDE Pawn is:

1  1  0  1     1
1  1  1  1     2
1  1 -1  1     2
1  1  0  2   16577 // pawn(1)
1  1  1  1     4
1  1 -1  1     4
0

The first 3 lines would suffice for the Shatranj Pawn; each line starts with the number of legs (always 1 here, as Pawns only have simple moves), the forward and sideway step size, the 'range' (= number of times the step can be repeated) and finally a code to indicate what the move can do (2 = capture, 1 = non-capture, e.p. capture = 4) and other details (like whether it is a virgin-only move). So the 4th line is the double-push, the 5th and 6th are the e.p. captures. For your bare Pawn you would leave these lines out. The final 0 indicates that the definition ends there, and that the moves that follow (if any) are for another piece. The move specifications for a piece should always end with such a 0.

In the example I copied this from the white Pawn was the first piece, so it starts at element 1 of legdefs. The special moves of that Pawn start at element 16 (as the three normal moves each take 5 numbers to describe). That means that just behind legdefs there is a line

def P cond #0 1 16;

that tells the code that the move definitions of piece P start at 1 (normal moves) and 16 (special moves = moves having side effect, such as creation of e.p. rights, or disappearance of pieces elsewhere). For pieces without special moves the latter number should always be 0. So for the bare Pawn you would have to add a line there like

def X cond #0 ... 0;

where the ... is the location in legdefs where the move definition starts.