From 209d916a042c8dec3dbddce57cc6c48bfd7407e8 Mon Sep 17 00:00:00 2001 From: GearsDatapacks Date: Sat, 13 Sep 2025 10:32:21 +0100 Subject: [PATCH] Fix insufficient material detection --- src/starfish/internal/game.gleam | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/starfish/internal/game.gleam b/src/starfish/internal/game.gleam index b616832..a6488df 100644 --- a/src/starfish/internal/game.gleam +++ b/src/starfish/internal/game.gleam @@ -464,14 +464,17 @@ fn castling_to_string(castling: Castling) -> String { } pub fn is_insufficient_material(game: Game) -> Bool { - { - game.black_pieces.pawn_material == 0 && game.white_pieces.pawn_material == 0 - } + game.black_pieces.pawn_material == 0 + && game.white_pieces.pawn_material == 0 && { game.black_pieces.non_pawn_material == board.bishop_value || game.black_pieces.non_pawn_material == board.knight_value - || game.white_pieces.non_pawn_material == board.bishop_value + || game.black_pieces.non_pawn_material == 0 + } + && { + game.white_pieces.non_pawn_material == board.bishop_value || game.white_pieces.non_pawn_material == board.knight_value + || game.white_pieces.non_pawn_material == 0 } } -- 2.51.2