Check out Janggi (Korean Chess), our featured variant for December, 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 Sun, Aug 2, 2020 07:04 AM EDT:

I ran again into a problem. I am trying to generate an array of squares reachable by a ride in a given direction, through

set tosqrs ride #cursqr #dx #dy

where cursqr is a formal parameter to the NextLeg subroutine, and dx and dy are my variables. When I follow this by

print join "from=" #cursqr;
print join "dx=" #dx;
print join "dy=" #dy;
print join "leg=" #legindex;
printr tosqrs;

it prints something like this, though:

from=f8
dx=0
dy=-2
leg=48
Array
(
    [0] => Array
        (
            [0] => f6
        )
    [1] => -2
)

Instead of the expected array of squares I get an array that always has two elements, where the second element always has the value of dy and the first element is always an array containing a single square, namely the first square on the path. It looks a lot like the ride operator fails to absorb its third argument, leaving it for the set command to group it with the returned result into an array. Yet it must have seen the operand, because the first square in the array it returns took it into account. And it fails to return the remaining squares on the path; f4 would also have been empty.

[Edit] It seems the array that is the first element does not always contain just one square. Apparently it continues the ride for as long as the squares are occupied, rather than empty...