In case you didn’t catch that, don’t feel bad, I didn’t either. It is French for “Endgame problem”. The rest of the issue on the tracker went like this: “Quand il n’y a plus que les deux rois, la partie ne s’arrête pas.” Which translates to “When there are only the two kings, the game does not stop.” You can read the full issue on the tracker here:

https://gitlab.com/alaskalinuxuser/app_JustChess/-/issues/16

The problem was that I didn’t have any function to check for insufficient material. There was a function for checking stalemate, or checkmate, but nothing to check the board and determine if you have too little material to win the game. So, I added one with this commit:

https://gitlab.com/alaskalinuxuser/app_JustChess/-/commit/954d48a95856efe1d706d71e3c969ad50b709a1a

The main idea was just to have a function call that runs through all the pieces of the board. It starts by assuming that you do not have enough pieces left to win the game, and then uses a switch/case block to check each piece. If the white or black pieces have either a rook, a queen, or a pawn, the game still has sufficient material.

if (wKnightBishop > 1 || bKnightBishop > 1){
            // Because there is more than one knight or bishop or combo, then there is sufficient material.
            insufficient = false;
        }

And, using the above code, with the switch/case block adding a point for each knight or bishop, then having more than one knight and/or bishop will result in still having enough material.

There are three technicalities that I forgot, though, which is having one knight each, or one bishop each of opposite color, or, this will claim that you have sufficient material with two bishops, even if they are both the same color. Technically, the first two are not a draw, because it is possible to still have a checkmate. However, it is practically a draw, because most sane players wouldn’t fall trap to it. But, I’ll have to come back to that. The last one is technically a draw, but the engine doesn’t know it.

For now, it is much more playable, and this insufficient material rule will work in almost all games, based off of a search of all rated classical games played on Lichess last weekend that ended in a draw due to insufficient material (September 30 through October 1, https://lichess.org/games/search?ratingMin=400&ratingMax=2900&hasAi=0&perf=3&mode=1&status=34&dateMin=2023-09-30&dateMax=2023-10-01&sort.field=d&sort.order=desc). And you can download the latest version of the app here:

https://gitlab.com/alaskalinuxuser/app_JustChess/-/tree/master/app?ref_type=heads

Or hopefully soon on F-Droid.

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *