[gnome-chess/gnome-3-8] Player on move should be considered in check for threefold repetition
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/gnome-3-8] Player on move should be considered in check for threefold repetition
- Date: Tue, 20 Aug 2013 00:24:00 +0000 (UTC)
commit f7398e708b539c2933129c91dca0c00d02e135b0
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 567caed..a2cda1a 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -415,10 +415,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]