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 Courier Developer's Guide. Learn how to design and program Chess variants for Game Courier.[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Mon, Dec 20, 2004 06:10 PM UTC:
Over the weekend, I added the ability to use parentheses for expressing
arrays. For example, this will now set an array of all white pieces in
Chess:

set white (K Q R B N P);

Arrays are parsed recursively, so that nested parentheses will yield
multi-dimensional arrays.

When lines are evaluated by the Polish notation calculator, the contents
of arrays are not automatically evaluated. For example

set a * (+ 4 5) (- 9 5)

should not evaluate to 36.

But arrays may be conditionally evaluated by the logical operators and,
or, nor, nand, and cond, and also be eval and fn. For example,

set a * eval (+4 5) eval (-9 5)

would yield 36.

When given arrays as arguments, the binary logical operators will evaluate
the first array first, then evaluate the second only if its value is needed
to determine the value of the expression. For example,

set a or (== 4 4) (!= 4 7)

will evaluate only (== 4 4)

The cond operator is the equivalent of ?: in C or PHP. It will evaluate an
expression, and if it is true, it will evaluate the array following the
expression, but if it is false, it will evaluate the second array
following the expression. For example,

cond != 6 6 (== 7 9) (<= 9 7)

will evaluate (<= 9 7) but not (== 7 9)

Last night, there was still a problem with using parentheses with
recursive functions. That problem is now fixed. It is now possible to
write a recursive function like this one for finding a number's
factorial:

def fac cond equal #0 1 1 (* #0 fn fac dec #0);

Note that #0 is now the first placeholder instead of #1. I changed all the
placeholders in chess.txt to accomodate this.

This particular function has been tested and shown to work. It first
checks whether the value passed to it is equal to 1, with 'equal #0 1'.
If it is 1, it returns 1. Otherwise, it evaluates the array (* #0 fn fac
dec #0), which multiples the value passed to the function, #0, with a
recursive function call of one less than the value passed, dec #0.