[gnome-chess/gnome-3-8] King and bishop can checkmate king and bishop of opposite color



commit b905e3d78d9ea8128fd133e01cb1d7ad82432ac4
Author: Michael Catanzaro <mike catanzaro gmail com>
Date:   Sun May 26 13:25:07 2013 -0500

    King and bishop can checkmate king and bishop of opposite color
    
    https://en.wikipedia.org/wiki/Checkmate#Rare_checkmates
    (cherry picked from commit af8f4d798d0bb0568233b3d275356d8633e51bc8)

 src/chess-game.vala |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/chess-game.vala b/src/chess-game.vala
index c7aa2f2..47825f0 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -1001,6 +1001,15 @@ public class ChessState
                 return true;
             if ((black_bishop_count > 0 || black_knight_count > 0) && white_knight_count > 0)
                 return true;
+
+            /* King and bishop can checkmate vs. king and bishop if bishops are on opposite colors */
+            if (white_bishop_count > 0 && black_bishop_count > 0)
+            {
+                if (white_bishop_on_white_square && black_bishop_on_black_square)
+                    return true;
+                else if (white_bishop_on_black_square && black_bishop_on_white_square)
+                    return true;
+            }
         }
 
         return false;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]