Check out Makruk (Thai Chess), our featured variant for March, 2025.


[ 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

Vanguard Chess. Game Courier preset for Vanguard Chess. (16x16, Cells: 256) [All Comments] [Add Comment or Rating]
H. G. Muller wrote on Thu, Jul 4, 2024 05:38 PM UTC in reply to Daniel Zacharias from 04:49 PM:

@Fergus - I have a problem with the following GAME code:

  set royal array; // empty array
  do while < #i count #myroyal:
    set type elem #i #myroyal;     // next royal type
    set cnt elem #type piececount; // count them
    if #cnt:
      set nr + #nr #cnt;
      push royal #type;
    endif;
    inc i;
  loop;

The purpose was to make (from the array 'myroyal' of royal types) an array 'royal' of royals that are actually present on the board. The problem is that 'cnt' doesn't get the value zero when the key '#type' is not in the array. So the "if #cnt:" is always satisfied, and the non-present royalas get listed in the array 'royal' as well.

How could this be solved?

[Edit] I did find a solution: use "if + 0 #cnt:" instead of "if #cnt:". Apparently dereferencing a variable with value 'undefined' produces a text string, but using it as an arithmetic operand treats it as 0.

@Daniel - It appears this solves the problem in the preset, which was caused by the first piece type mentioned in the 'royal' array being a Pr, which was not present in the initial setup.