[gnome-games] glchess: Fix insufficient material algorithm again



commit 5c46c36c61aa5dd488e8486f7a56c67433822e12
Author: Robert Ancell <robert ancell gmail com>
Date:   Fri Jun 11 11:13:51 2010 +1000

    glchess: Fix insufficient material algorithm again

 glchess/src/lib/chess/board.py |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/glchess/src/lib/chess/board.py b/glchess/src/lib/chess/board.py
index afc89be..3fde47b 100644
--- a/glchess/src/lib/chess/board.py
+++ b/glchess/src/lib/chess/board.py
@@ -429,18 +429,21 @@ class ChessBoardState:
                         blackBishopOnBlackSquare = True
                     blackBishopCount += 1
 
+            # Three knights versus king can checkmate
+            if whiteKnightCount > 2 or blackKnightCount > 2
+                return True
+
             # Bishop and knight versus king can checkmate
             if whiteBishopCount > 0 and whiteKnightCount > 0:
                 return True
             if blackBishopCount > 0 and blackKnightCount > 0:
                 return True
 
-            # King and bishop versus king and bishop can checkmate as long as the bishops are on opposite colours
-            if whiteBishopCount > 0 and blackBishopCount > 0:
-                bishopsOnOppositeSquares = (whiteBishopOnWhiteSquare and blackBishopOnBlackSquare) or \
-                                        (blackBishopOnWhiteSquare and whiteBishopOnBlackSquare)
-                if bishopsOnOppositeSquares:
-                    return True
+            # King and bishops versus king can checkmate as long as the bishops are on both colours
+            if whiteBishopOnWhiteSquare and whiteBishopOnBlackSquare:
+                return True;
+            if blackBishopOnWhiteSquare and blackBishopOnBlackSquare:
+                return True;
 
         return False
 



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