Half Move Clock Confusion

General discussion about computer chess...
HumbleProgrammer
Posts: 40
Joined: Sat Jun 19, 2010 11:00 pm
Real Name: Lee Neuse

Half Move Clock Confusion

Post by HumbleProgrammer » Thu Jan 10, 2013 12:22 am

I am using the game below as a sample game to test various bits and pieces of chess software, and noticed something unusual. I was using HIARCS Chess Explorer v1.2 to generate test FEN strings, and after Black castles on move 30, the Half Move Clock was reset to zero. My understanding is that the half move clock is "...the number of moves since the last pawn move or capture." and since castling is neither a pawn move nor a capture, I thought the FEN string was wrong. Much to my surprise, however, Fritz 12 did precisely the same thing as did Deep Shredder 12!

So here is my question: are all three mainstream chess GUIs reporting the wrong value for the half move clock, or am I misinterpreting it's purpose?

Half-Confused.
,,,^..^,,,

P.S. After submitting this message, I noticed that pgn4web does NOT reset the Half Move Clock, and reports it as 2.

[Event "II American Continental"]
[Site "Buenos Aires ARG"]
[Date "2003.08.19"]
[Round "3"]
[White "Campora,D"]
[Black "Granda Zuniga,J"]
[Result "1/2-1/2"]
[BlackElo "2641"]
[ECO "B47"]
[EventDate "2003.08.17"]
[Source "twic459.pgn game #157"]
[WhiteElo "2510"]

1.e4 c5 2.Nf3 Nc6 3.d4 cxd4 4.Nxd4 e6 5.Nc3 Qc7 6.g3 a6 7.Bg2 Nge7 8.Nb3 Ne5
9.O-O b5 10.f4 Nc4 11.a4 b4 12.Ne2 Bb7 13.Qd3 g5 14.fxg5 Ng6 15.Nf4 Nge5
16.Qe2 h6 17.Nd3 hxg5 18.Bxg5 Be7 19.Bf4 Qb6+ 20.Kh1 Ng6 21.a5 Qb5 22.e5 Bd5
23.Nd4 Qb7 24.b3 Bxg2+ 25.Qxg2 Qxg2+ 26.Kxg2 Nxf4+ 27.Rxf4 Ne3+ 28.Kh1 Nd5
29.Rf3 f5 30.Nb2 O-O-O 31.Kg2 Rdg8 32.Nc4 Rg4 33.Rd1 f4 34.Ne2 fxg3 35.hxg3
Bc5 36.Nf4 Nc3 37.Rh1 Rhg8 38.Nd3 Be7 39.Rh7 R4g7 40.Rxg7 Rxg7 41.Nf4 Kc7
42.Nh5 Rg5 43.Nf6 Kc6 44.Kh3 Nb5 45.g4 Rg6 46.Kh4 Rh6+ 47.Kg5 Rh2 48.Kg6 Nd4
49.Rd3 Bc5 50.Kf7 Rxc2 51.g5 Rc3 52.Rd1 Rxb3 53.g6 Rg3 54.g7 Nf5 55.g8=N Rg7+
56.Ke8 d5 57.exd6 Nxd6+ 58.Nxd6 Bxd6 59.Rc1+ Kb5 60.Rd1 Bc5 61.Nh6 Rg1 62.Rd7
Re1 63.Nf7 b3 64.Rb7+ Ka4 65.Nd7 Bd4 66.Nd8 Ka3 67.Nc6 e5 68.Nb4 e4 69.Nxa6
b2 70.Nac5 b1=Q 71.Rxb1 Rxb1 72.a6 Bxc5 73.Nxc5 Rb8+ 74.Kd7 e3 75.Kc7 Rf8
76.a7 e2 77.Nd3 Kb3 78.Nc1+ Kc4 79.Nxe2 Rf7+ 80.Kb8 Rxa7 1/2-1/2

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Half Move Clock Confusion

Post by hyatt » Thu Jan 10, 2013 2:50 am

HumbleProgrammer wrote:I am using the game below as a sample game to test various bits and pieces of chess software, and noticed something unusual. I was using HIARCS Chess Explorer v1.2 to generate test FEN strings, and after Black castles on move 30, the Half Move Clock was reset to zero. My understanding is that the half move clock is "...the number of moves since the last pawn move or capture." and since castling is neither a pawn move nor a capture, I thought the FEN string was wrong. Much to my surprise, however, Fritz 12 did precisely the same thing as did Deep Shredder 12!

So here is my question: are all three mainstream chess GUIs reporting the wrong value for the half move clock, or am I misinterpreting it's purpose?

Half-Confused.
,,,^..^,,,

P.S. After submitting this message, I noticed that pgn4web does NOT reset the Half Move Clock, and reports it as 2.

[Event "II American Continental"]
[Site "Buenos Aires ARG"]
[Date "2003.08.19"]
[Round "3"]
[White "Campora,D"]
[Black "Granda Zuniga,J"]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/2-1/2

No, it is the number of moves since the last IRREVERSIBLE move. A castle move, a capture, or a pawn move can't be undone.

HumbleProgrammer
Posts: 40
Joined: Sat Jun 19, 2010 11:00 pm
Real Name: Lee Neuse

Re: Half Move Clock Confusion

Post by HumbleProgrammer » Thu Jan 10, 2013 4:30 am

...it is the number of moves since the last IRREVERSIBLE move.
Hence the cause of my confusion. I understand the utility in interpreting it as the number if plies since the last irreversible move -- particularly in the context of chess algorithms -- because it is a convenient boundary for finding repeated positions. Given that an irreversible move changes the board state in such a way that no position prior to the move could ever match a position occurring after the move is made, a "back to front" search for repetition of position can be terminated as soon as an irreversible move is encountered. Nonetheless, I have cause to respectfully disagree with this notion.

Most definitions of the FEN notation state that the Half Move clock is intended to determine when the "50 move" draw rule comes into play, which is independent of the "repeated position/perpetual check" rule. Nothing in the definition of the "50 move rule" makes any reference to irreversible moves or changes in board position; based on the statements below, castling should not reset the Half Move clock.

From http://www.freechess.org/Help/HelpFiles/fen.html: This number is the count of halfmoves (or ply) since the last pawn advance or capturing move. This value is used for the fifty move draw rule.

From http://www.fide.com/component/handbook/ ... ew=article (Section 5.2e): The game may be drawn if each player has made at least the last 50 consecutive moves without the movement of any pawn and without any capture.

Please accept my apology for harping on a matter of such triviality...
Humble Programmer
,,,^..^,,,

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: Half Move Clock Confusion

Post by pgn4web » Thu Jan 10, 2013 11:42 am

HumbleProgrammer wrote:P.S. After submitting this message, I noticed that pgn4web does NOT reset the Half Move Clock, and reports it as 2.
Glad to see that I got this right, following the letter of the FIDE rules.
It sounds odd though, I just emailed the question to the guy that writes most of the rules, you might read his answer on Guert Gijssen column on http://www.chesscafe.com

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: Half Move Clock Confusion

Post by pgn4web » Thu Jan 10, 2013 12:39 pm

HumbleProgrammer wrote:Much to my surprise, however, Fritz 12 did precisely the same thing as did Deep Shredder 12!
Did they use the same chessbase interface?
I did a quick check with a recent version of scid and winboard and both apply the rule for the 50 moves counter as described in the PGN specs and in the FIDE rules (i.e. castling is NOT resetting the counter).

lucasart
Posts: 201
Joined: Mon Dec 17, 2012 1:09 pm
Contact:

Re: Half Move Clock Confusion

Post by lucasart » Thu Jan 10, 2013 1:08 pm

hyatt wrote:
HumbleProgrammer wrote:I am using the game below as a sample game to test various bits and pieces of chess software, and noticed something unusual. I was using HIARCS Chess Explorer v1.2 to generate test FEN strings, and after Black castles on move 30, the Half Move Clock was reset to zero. My understanding is that the half move clock is "...the number of moves since the last pawn move or capture." and since castling is neither a pawn move nor a capture, I thought the FEN string was wrong. Much to my surprise, however, Fritz 12 did precisely the same thing as did Deep Shredder 12! 1

So here is my question: are all three mainstream chess GUIs reporting the wrong value for the half move clock, or am I misinterpreting it's purpose?

Half-Confused.
,,,^..^,,,

P.S. After submitting this message, I noticed that pgn4web does NOT reset the Half Move Clock, and reports it as 2.

[Event "II American Continental"]
[Site "Buenos Aires ARG"]
[Date "2003.08.19"]
[Round "3"]
[White "Campora,D"]
[Black "Granda Zuniga,J"]
[Result "1/2-1/2"]
[BlackElo "2641"]
[ECO "B47"]
[EventDate "2003.08.17"]
[Source "twic459.pgn game #157"]
[WhiteElo "2510"]

1.e4 c5 2.Nf3 Nc6 3.d4 cxd4 4.Nxd4 e6 5.Nc3 Qc7 6.g3 a6 7.Bg2 Nge7 8.Nb3 Ne5
9.O-O b5 10.f4 Nc4 11.a4 b4 12.Ne2 Bb7 13.Qd3 g5 14.fxg5 Ng6 15.Nf4 Nge5
16.Qe2 h6 17.Nd3 hxg5 18.Bxg5 Be7 19.Bf4 Qb6+ 20.Kh1 Ng6 21.a5 Qb5 22.e5 Bd5
23.Nd4 Qb7 24.b3 Bxg2+ 25.Qxg2 Qxg2+ 26.Kxg2 Nxf4+ 27.Rxf4 Ne3+ 28.Kh1 Nd5
29.Rf3 f5 30.Nb2 O-O-O 31.Kg2 Rdg8 32.Nc4 Rg4 33.Rd1 f4 34.Ne2 fxg3 35.hxg3
Bc5 36.Nf4 Nc3 37.Rh1 Rhg8 38.Nd3 Be7 39.Rh7 R4g7 40.Rxg7 Rxg7 41.Nf4 Kc7
42.Nh5 Rg5 43.Nf6 Kc6 44.Kh3 Nb5 45.g4 Rg6 46.Kh4 Rh6+ 47.Kg5 Rh2 48.Kg6 Nd4
49.Rd3 Bc5 50.Kf7 Rxc2 51.g5 Rc3 52.Rd1 Rxb3 53.g6 Rg3 54.g7 Nf5 55.g8=N Rg7+
56.Ke8 d5 57.exd6 Nxd6+ 58.Nxd6 Bxd6 59.Rc1+ Kb5 60.Rd1 Bc5 61.Nh6 Rg1 62.Rd7
Re1 63.Nf7 b3 64.Rb7+ Ka4 65.Nd7 Bd4 66.Nd8 Ka3 67.Nc6 e5 68.Nb4 e4 69.Nxa6
b2 70.Nac5 b1=Q 71.Rxb1 Rxb1 72.a6 Bxc5 73.Nxc5 Rb8+ 74.Kd7 e3 75.Kc7 Rf8
76.a7 e2 77.Nd3 Kb3 78.Nc1+ Kc4 79.Nxe2 Rf7+ 80.Kb8 Rxa7 1/2-1/2

No, it is the number of moves since the last IRREVERSIBLE move. A castle move, a capture, or a pawn move can't be undone.
I beg to differ. In doubt, do not listen to anyone on this forum, and have a look at the official FIDE rules:
http://www.fide.com/FIDE/handbook/LawsOfChess.pdf
Article 5.2.e says:
The game may be drawn if each player has made at least the last 50 consecutive
moves without the movement of any pawn and without any capture.
So the bug is in HIARCS Chess Explorer.

I agree that in the spirit of the rule, the idea is irreversibility. But that's not what the rule says. And in a way, a castling move can be undone, in several moves, although it still loses the castling rights, the position is restored. And restoring the position (regardless of castling right difference) is what matters. For example, the 3 repetion rule is triggered if a position is repeated three times, even with different values of en passant square and castling rights.
"Talk is cheap. Show me the code." -- Linus Torvalds.

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: Half Move Clock Confusion

Post by pgn4web » Thu Jan 10, 2013 1:19 pm

lucasart wrote:I agree that in the spirit of the rule, the idea is irreversibility. But that's not what the rule says. And in a way, a castling move can be undone, in several moves, although it still loses the castling rights, the position is restored. And restoring the position (regardless of castling right difference) is what matters. For example, the 3 repetion rule is triggered if a position is repeated three times, even with different values of en passant square and castling rights.
Regarding the 50 moves rules you are right.
Regarding the threefold position repetition you are wrong. Read article 9.2 of the document you posted: "Positions as in (a) and (b) are considered the same, if the same player has the move, pieces of the same kind and colour occupy the same squares, and the possible moves of all the pieces of both players are the same."
Hence the confusion from the inconsistent approach.

lucasart
Posts: 201
Joined: Mon Dec 17, 2012 1:09 pm
Contact:

Re: Half Move Clock Confusion

Post by lucasart » Thu Jan 10, 2013 1:34 pm

pgn4web wrote:
lucasart wrote:I agree that in the spirit of the rule, the idea is irreversibility. But that's not what the rule says. And in a way, a castling move can be undone, in several moves, although it still loses the castling rights, the position is restored. And restoring the position (regardless of castling right difference) is what matters. For example, the 3 repetion rule is triggered if a position is repeated three times, even with different values of en passant square and castling rights.
Regarding the 50 moves rules you are right.
Regarding the threefold position repetition you are wrong. Read article 9.2 of the document you posted: "Positions as in (a) and (b) are considered the same, if the same player has the move, pieces of the same kind and colour occupy the same squares, and the possible moves of all the pieces of both players are the same."
Hence the confusion from the inconsistent approach.
Well I learnt something too, then :)
What is interesting is the case where you have a 3 repetition where the position are the same "visually" the possible moves are the same, even though en-passant or castling may differ (for eg. en passant is impossible due to a pin, or castling cannot be played in that position, although can at a later stage).

The 3 move FIDE rule was typically not written with programming implementation in mind. Just imagine if you want to obey that silly rule to the letter, you should generate all legal moves to verify (no one does that as I would be overkill in performance).
"Talk is cheap. Show me the code." -- Linus Torvalds.

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: Half Move Clock Confusion

Post by pgn4web » Thu Jan 10, 2013 2:09 pm

lucasart wrote:The 3 move FIDE rule was typically not written with programming implementation in mind.
Chess is a game for people and rules should be written with human players in mind, certainly not computers and their programmers.
Anyway, as I said, I sent a note to Guert Gijssen, he practically writes the FIDE rules, let's wait for his explanation of this apparent inconsistency between the 50 moves rules and the threefold position repetition; he's usually very helpful answering questions, so stay tuned...

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Half Move Clock Confusion

Post by hyatt » Fri Jan 11, 2013 11:51 pm

I actually agree with everyone. Crafty does this correctly, always has. It was my memory that was broken. :) castling does change the repetition detection, but not the 50 move counter...

Post Reply