[gnome-chess] Player on move should be considered in check for threefold repetition



commit eab291007a1580f3222849527fd8578d94c305b8
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Aug 19 19:21:55 2013 -0500

    Player on move should be considered in check for threefold repetition
    
    The rule is that everything is the same *with the same player to move*
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705956

 src/chess-game.vala |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/chess-game.vala b/src/chess-game.vala
index 2c8bb63..e609630 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -425,10 +425,17 @@ public class ChessState
 
     public bool equals (ChessState state)
     {
-        /* Check first if there is the same layout of pieces (unlikely),
-         * then that the move castling and en-passant state are the same */
+        /*
+         * Check first if there is the same layout of pieces (unlikely),
+         * then that the same player is on move, then that the move castling
+         * and en-passant state are the same.  This follows the rules for
+         * determining threefold repetition:
+         *
+         * https://en.wikipedia.org/wiki/Threefold_repetition
+         */
         if (piece_masks[Color.WHITE] != state.piece_masks[Color.WHITE] ||
             piece_masks[Color.BLACK] != state.piece_masks[Color.BLACK] || 
+            current_player.color != state.current_player.color ||
             can_castle_kingside[Color.WHITE] != state.can_castle_kingside[Color.WHITE] ||
             can_castle_queenside[Color.WHITE] != state.can_castle_queenside[Color.WHITE] ||
             can_castle_kingside[Color.BLACK] != state.can_castle_kingside[Color.BLACK] ||


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