bhlangonijr / chesslib

chess library for legal move generation, FEN/PGN parsing and more
Apache License 2.0
229 stars 80 forks source link

Improvement for insufficient material #42

Closed dlbbld closed 3 years ago

dlbbld commented 4 years ago

Just a suggestion to improve the insufficient material check. KBvKB with same coloured bishops is insufficient material, that is checked. But King versus King with any number of same coloured bishops on the board is also insufficient material, that could also be checked. I've seen that in the python chess API.

https://syzygy-tables.info/?fen=B3k3/8/8/8/8/8/8/4KB2_w_-_-_0_1

final Board board = new Board();
board.loadFromFen("B3k3/8/8/8/8/8/8/4KB2 w - - 0 1");
System.out.println(board.isInsufficientMaterial()); // false but actually true

https://syzygy-tables.info/?fen=B1b1k3/3b4/4b3/8/8/8/8/4KB2_w_-_-_0_1

final Board board = new Board();
board.loadFromFen("B1b1k3/3b4/4b3/8/8/8/8/4KB2 w - - 0 1");
System.out.println(board.isInsufficientMaterial()); // false but actually true