Check out Glinski's Hexagonal Chess, our featured variant for May, 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

GAME code table-driven move generator[Subject Thread] [Add Response]
H. G. Muller wrote on Tue, Jul 28, 2020 09:09 PM UTC:

OK, that helps. My code now seems to work! When I move the King 3 steps to the left or right it automatically moves the Rook to the other side. Unless I move the King or the Rook back and forth first to destroy their virginity; then it just moves the King because it doesn't match any pseuo-legal castling. So that completes phase 2.

Next phase is to automate e.p. capture. This will again require a lot of new infra-structure, for handling the e.p. rights. In XBetza moves can be specified as rights-generating in several ways: a lame leap can generate e.p. rights on the square where it could be blocked, and slides can generate e.p. rights on every square they pass through. In the diagram it proved convenient to also use 'royal e.p. capture': e.p. rights created by moving a royal piece can be consumed by any capture, not just by pieces that have been defined as e.p.-capable. This then prevents the royal to pass through check. Castlings also create e.p. rights, even on the square the King starts from, to prevent castling out of check.

So moves can in principle create e.p. rights on a lot of squares, along a complex trajectory; XBetza would allow you to define a Griffon as e.p.-capturable piece. It seems thus best to create an array epsqrs, which contains all the squares with rights created in the previous move, and use match to test whether the current destiation is one of those.

This brings me to the following question:

How can I create an array in GAME code? I know I can write the elements in parentheses, but to use that there must be a fixed number of elements, all known in advance. But what if I want to do it in a loop, to add the elements one by one? Is there a way to create an empty array? Can I push something to a so-far unused variable to create an array of one element? Can I push something to a scalar variable to make it an array of two elements? Can I use setelem on a so-far unused variable?