Draw by insufficient material

Discussion of chess software programming and technical issues.

Moderator: Ras

Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Draw by insufficient material

Post by Sven »

hgm wrote:I am sure I would have no problems programming it. But I don't think a desicion about which claims to accept and which to reject should be taken unilaterally. Otherwise we get into a situation where some claims are rejected by WinBoard but OK on, say Arena or ChessGUI, while others are accepted by WinBoard but lead to a forfeit with, say, Arena.
Which other GUI does automatically forfeit an engine due to illegal draw claim?

If there are other GUIs implementing this policy then I would expect from them, too, that they do not miss to implement trivial draw checks with absolutely no relevant cost and no significant risk.

Once again: it is trivial, every GUI can do it. Perhaps like this "C++ pseudocode" (not compiled):

Code: Select all

bool isKNK()
{
    return (totalPieceCount(White) == 2 && totalPieceCount(Black) == 1 && pieceCount(White, Knight) == 1)
        || (totalPieceCount(White) == 1 && totalPieceCount(Black) == 2 && pieceCount(Black, Knight) == 1);
}

bool isKBxKBx_withLikeBishops()
{
    if (totalPieceCount(White) + totalPieceCount(Black) != 2 + pieceCount(White, Bishop) + pieceCount(Black, Bishop)) {
        return false;
    }
    // no other pieces than kings and bishops are present (this includes the cases KK, KBK, KBKB, KBBKB, ...)

    int cBishops = COLOR_UNDEFINED;
    bool ok = true;
    static int const color[2] = { White, Black }; // in case you have different values than White=0/Black=1

    for (int c = 0; c < 2 && ok; c++) { 
        for (int i = 0; i < pieceCount(color[c], Bishop) && ok; i++) {
            // get next bishop, e.g. from piece list, and get its square color
            int cThisBishop = colorOfSquare(getBishopSquare(color[c], i));

            if (cBishops == COLOR_UNDEFINED) {
                cBishops = cThisBishop;
            } else

            if (cThisBishop != cBishops) { // found a bishop on different color
                ok = false;
            }
        }
    }
    return ok;
}
 
bool isDrawByInsufficientMaterial()
{
    return isKNK() || isKBxKBx_withLikeBishops();
}
Sven
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Draw by insufficient material

Post by bob »

hgm wrote:
bob wrote:In this position, they don't. But I do not believe the "insufficient material to force checkmate" applies. I don't have my rule book here at home, but I suspect the only rule that will apply is the rule about offering/accepting draws...
You old-timers have obsolete rule books! :lol:

This tends to happen with books. For the rules as they currently apply, look on the FIDE website.
I actually have a new rule book. I knew there was a provision for "able to force mate no matter how unskilled the defense" was there, but I had thought it was under "insufficient material" when it is not...

:)