Check out Smess, our featured variant for February, 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

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 Wed, Oct 4, 2023 12:45 AM UTC in reply to Daniel Zacharias from Tue Oct 3 11:15 PM:

The same thing was happening. Since the code checks the legality of an actual move after it has moved the pieces, the destination space is always occupied at that time. So, the problem is just the same as it is for a potential move that is a capture.

I think I fixed it by changing this code:

function logleap ($from,  $to,  $ra) {
    global $map,  $space;

    $ns = $from;
    for ($i = 0; $i < count($ra); $i++) {
        $dir = $ra[$i];
        $temp = false;
        if (is_array($dir)) {
            if (($temp = logleap($from,  $to,  $dir)) == $to)
                return $temp;
        }
        elseif (isset($map[$ns][$dir]))
            $ns = $map[$ns][$dir];
        else
            $ns = false;
        if ($space[$ns] != '@')
            break;
    }
    if (($temp == false) && ($i < count($ra)))
        return false;
    return $temp ? $temp : $ns;
}

to this:

function logleap ($from,  $to,  $ra) {
    global $map,  $space;

    $ns = $from;
    for ($i = 0; $i < count($ra); $i++) {
        if (($i > 0) && ($space[$ns] != '@'))
            break;
        $dir = $ra[$i];
        $temp = false;
        if (is_array($dir)) {
            if (($temp = logleap($from,  $to,  $dir)) == $to)
                return $temp;
        }
        elseif (isset($map[$ns][$dir]))
            $ns = $map[$ns][$dir];
        else
            $ns = false;
    }
    if (($temp == false) && ($i < count($ra)))
        return false;
    return $temp ? $temp : $ns;
}