Check out Alice Chess, our featured variant for June, 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 Thu, May 30 02:34 AM UTC:

In checking over which logical functions behaved the same as onlyif and unless, I determined that these should be and and nor. The documentation already correctly identified onlyif as behaving like and with only one argument, but it mistakenly said that unless behaved like or. I have now corrected this to say that it operates like nor.

However, in tests I ran, "m nor false" was returning 1 instead of m. I discovered there was a bug in the logic for nor. The part concerning only one argument had read like this:

if ($op2 === NULL) {
    if ((((array)$op1 === $op1) && polish($op1, $linenum, $substitutions)) || ($op1 == true))
        $output = array(false);
        $input = array();
}

There were a few problems with this. First, if $op1 was an array containing a false expression, it would then evaluate ($op1 == true). Second, if $op1 wasn't equal to true, it would return false even if $op1 was a non-empty value. Third, "$input = array()" would execute even if the previous conditional were false, because without braces, it was not actually in the scope of the if-statement. So I changed the code to this:

if ($op2 === NULL) {
    if ((array)$op1 === $op1) {
        if (polish($op1, $linenum, $substitutions)) {
            $output = array(false);
            $input = array();
        }
    }
    elseif ($op1 != false) {
        $output = array(false);
        $input = array();
    }
}

This code eliminates the issues I described above, and it allows "print m nor false" to print m just like "print g unless false" prints g.

I made similar changes to nand. I'll look into whether I should do the same for and and or, as each has a similar disjunctive condition, but it's too late at night to spend time thinking about it now.

I'm not sure if it's mentioned in the documentation, but the logical operators can evaluate expressions in parentheses, but unless and onlyif do not. So, for these two, (false) evaluates to true, whereas it should evaluate to false for the logical operators. I will test things out better tomorrow to make sure the logical operators are behaving correctly.