[gnome-games] glchess: Remove redundant code from new insufficient material algorithm



commit 7d41f6bd6e5118076e951b779ab7d1ffc9a23e0d
Author: Robert Ancell <robert ancell gmail com>
Date:   Fri Jun 11 09:57:37 2010 +1000

    glchess: Remove redundant code from new insufficient material algorithm

 glchess/src/lib/chess/board.py |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/glchess/src/lib/chess/board.py b/glchess/src/lib/chess/board.py
index 5ed5828..afc89be 100644
--- a/glchess/src/lib/chess/board.py
+++ b/glchess/src/lib/chess/board.py
@@ -429,11 +429,6 @@ class ChessBoardState:
                         blackBishopOnBlackSquare = True
                     blackBishopCount += 1
 
-            whiteMinorCount = whiteBishopCount + whiteKnightCount
-            blackMinorCount = blackBishopCount + blackKnightCount
-            bishopsOnOppositeSquares = (whiteBishopOnWhiteSquare and blackBishopOnBlackSquare) or \
-                                       (blackBishopOnWhiteSquare and whiteBishopOnBlackSquare)
-
             # Bishop and knight versus king can checkmate
             if whiteBishopCount > 0 and whiteKnightCount > 0:
                 return True
@@ -441,8 +436,11 @@ class ChessBoardState:
                 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 and bishopsOnOppositeSquares:
-                return True
+            if whiteBishopCount > 0 and blackBishopCount > 0:
+                bishopsOnOppositeSquares = (whiteBishopOnWhiteSquare and blackBishopOnBlackSquare) or \
+                                        (blackBishopOnWhiteSquare and whiteBishopOnBlackSquare)
+                if bishopsOnOppositeSquares:
+                    return True
 
         return False
 



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