Whats the easies way to make crafty ignore the 50 move rule?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Zenmastur
Posts: 919
Joined: Sat May 31, 2014 8:28 am

Whats the easies way to make crafty ignore the 50 move rule?

Post by Zenmastur »

Is there any parameter that can be changed that will affect its behavior in this regard?

Thanks, in advance.

Regards,

Forrest
Only 2 defining forces have ever offered to die for you.....Jesus Christ and the American Soldier. One died for your soul, the other for your freedom.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Whats the easies way to make crafty ignore the 50 move r

Post by zullil »

Zenmastur wrote:Is there any parameter that can be changed that will affect its behavior in this regard?

Thanks, in advance.

Regards,

Forrest
Well, it's not as simple as changing the value of a constant from 50 to some very large value. The number 50 (or related numbers) is hard-coded. For example, in evaluate.c I find:

Code: Select all

/*
 ************************************************************
 *                                                          *
 *  If we are running into the 50-move rule, then start     *
 *  dragging the score toward draw.  This is the idea of a  *
 *  "weariness factor" as mentioned by Dave Slate many      *
 *  times.  This avoids slamming into a draw at move 50 and *
 *  having to move something quickly, rather than slowly    *
 *  discovering that the score is dropping and that pushing *
 *  a pawn or capturing something will cause it to go back  *
 *  to its correct value a bit more smoothly.               *
 *                                                          *
 ************************************************************
 */
  if (Reversible(ply) > 80) {
    int iscale = 101 - Reversible(ply);

    score = DrawScore(1) + score * iscale / 20;
  }
  return score;
User avatar
Brunetti
Posts: 266
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: Whats the easies way to make crafty ignore the 50 move r

Post by Brunetti »

zullil wrote:Well, it's not as simple as changing the value of a constant from 50 to some very large value. The number 50 (or related numbers) is hard-coded.
Correct, but we can simply avoid the counter increasing by commenting out this line in Makemove():

Code: Select all

  Reversible(ply + 1)++;
Alex
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Whats the easies way to make crafty ignore the 50 move r

Post by zullil »

Brunetti wrote:
zullil wrote:Well, it's not as simple as changing the value of a constant from 50 to some very large value. The number 50 (or related numbers) is hard-coded.
Correct, but we can simply avoid the counter increasing by commenting out this line in Makemove():

Code: Select all

  Reversible(ply + 1)++;
Alex
Yeah, I should have thought of that. :wink:
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: Whats the easies way to make crafty ignore the 50 move r

Post by syzygy »

Not increasing the counter might disable other things such as draw by repetition checks.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Whats the easies way to make crafty ignore the 50 move r

Post by bob »

Brunetti wrote:
zullil wrote:Well, it's not as simple as changing the value of a constant from 50 to some very large value. The number 50 (or related numbers) is hard-coded.
Correct, but we can simply avoid the counter increasing by commenting out this line in Makemove():

Code: Select all

  Reversible(ply + 1)++;
Alex
That will screw up other things like repetition checking.

The first question I would ask is "why"? The 50 move rule is part of the official rules of the game, disabling it doesn't make any sense. Any more than disabling castling or en passant or whatever?

If I were going to disable it, I would probably just disable the checks for the thing going to 100 or more. Certainly in Repeat() (in repeat.c) should do the trick. This keeps the counter correct so that 3-fold repetition checks will work correctly, while disabling the 50 move counter's usage to end the game...
Zenmastur
Posts: 919
Joined: Sat May 31, 2014 8:28 am

Re: Whats the easies way to make crafty ignore the 50 move r

Post by Zenmastur »

bob wrote: That will screw up other things like repetition checking.

The first question I would ask is "why"? The 50 move rule is part of the official rules of the game, disabling it doesn't make any sense. Any more than disabling castling or en passant or whatever?

If I were going to disable it, I would probably just disable the checks for the thing going to 100 or more. Certainly in Repeat() (in repeat.c) should do the trick. This keeps the counter correct so that 3-fold repetition checks will work correctly, while disabling the 50 move counter's usage to end the game...
"Why?"

The 50 move rule has changed several times. If you want to analyze a game in which the 50 move rule wasn't in effect it makes it difficult since the program keeps returning evaluations near zero. If you want to analyze long endgames found in the table bases etc, its a problem as well. The problem is I've been doing both since they're related tasks. I was just hoping that there was a parameter that I could change in the personality section. This would make it a non-issue.

In the meantime I have a work around for this that works most of the time. I convert the game score to a bunch of FEN's and then use them individually or alternately take the pgn's and cut them up into 10 moves or smaller chunks (depends on how much material is still on the board) so the program wont invoke the rule during a long analysis. This works fine most of the time. I have run into a few instances where the analysis ran to max search plies. If this happens there is no good fix. The best plan is to play the line in the analysis, assuming it's accurate, and record the game and then cut it into chunks and then analyze the chunks as separate games. This is a real pain in the ass, so I've only tried it a couple of times without any usable results.

Regards,

Zen
Only 2 defining forces have ever offered to die for you.....Jesus Christ and the American Soldier. One died for your soul, the other for your freedom.
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: Whats the easies way to make crafty ignore the 50 move r

Post by syzygy »

Zenmastur wrote:The 50 move rule has changed several times. If you want to analyze a game in which the 50 move rule wasn't in effect it makes it difficult since the program keeps returning evaluations near zero.
There must be about 1 game in the history of chess where this matters (if there exists one at all).
If you want to analyze long endgames found in the table bases etc, its a problem as well.
Crafty, or any other engine, is pretty useless for analysing a long TB endgame.

To analyse a long TB endgame while ignoring the 50-move rule, just use:
http://www.k4it.de/index.php?topic=egtb&lang=en

Of course such endgames have little to do with FIDE chess.
User avatar
Brunetti
Posts: 266
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: Whats the easies way to make crafty ignore the 50 move r

Post by Brunetti »

syzygy wrote:There must be about 1 game in the history of chess where this matters (if there exists one at all).
Actually, in the latest Megadatabase there're 990 games for just the R+B vs R endgame between 1928 and 2001, when in a way or another, FIDE rules allowed more than 50 moves in some endgames like this one. 120 lasted at least 50 moves.

This is an interesting one; many top engines can't see the mate in the final moves because they return a draw score, as Forrest reported:
[pgn][Event "Sochi Chigorin Memorial"]
[Site "Sochi"]
[Date "1988.??.??"]
[Round "?"]
[White "Rodriguez Cespedes, Amador"]
[Black "Smagin, Sergey"]
[Result "0-1"]
[ECO "C92"]
[WhiteElo "2550"]
[BlackElo "2550"]
[PlyCount "264"]
[EventDate "1988.09.??"]
[EventType "tourn"]
[Event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5 83. Re1+ Kd5 84. Rf1
Ra6 85. Rd1+ Bd4 86. Kf7 Rf6+ 87. Ke7 Rf3 88. Ke8 Rg3 89. Kf7 Rg7+ 90. Kf8 Rb7
91. Ke8 Rg7 92. Kf8 Rh7 93. Kg8 Rd7 94. Re1 Rb7 95. Rd1 Ke5 96. Kf8 Rh7 97. Rc1
Kf5 98. Rc6 Bf6 99. Ra6 Bd4 100. Ra5+ Be5 101. Ra6 Rb7 102. Rc6 Bd4 103. Ke8
Ke5 104. Rg6 Bc3 105. Rc6 Bd4 106. Rg6 Bc3 107. Kf8 Rc7 108. Rg7 Bb4+ 109. Kg8
Rc8+ 110. Kh7 Kf6 111. Rg6+ Kf5 112. Rg7 Bf8 113. Rf7+ Kg5 114. Ra7 Kf6 115.
Ra6+ Kf5 116. Ra7 Bd6 117. Rf7+ Ke6 118. Rg7 Bf8 119. Rg2 Rc7+ 120. Kg8 Be7
121. Re2+ Kf6 122. Rf2+ Kg6 123. Rg2+ Bg5 124. Rf2 Bf6 125. Rg2+ Kf5 126. Ra2
Rd7 127. Re2 Be5 128. Rf2+ Ke6 129. Rf7 Rd1 130. Ra7 Rd8+ 131. Kh7 Kf5 132. Kh6
Rd2 0-1[/pgn]

Alex
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Whats the easies way to make crafty ignore the 50 move r

Post by bob »

Brunetti wrote:
syzygy wrote:There must be about 1 game in the history of chess where this matters (if there exists one at all).
Actually, in the latest Megadatabase there're 990 games for just the R+B vs R endgame between 1928 and 2001, when in a way or another, FIDE rules allowed more than 50 moves in some endgames like this one. 120 lasted at least 50 moves.

This is an interesting one; many top engines can't see the mate in the final moves because they return a draw score, as Forrest reported:
[pgn][Event "Sochi Chigorin Memorial"]
[Site "Sochi"]
[Date "1988.??.??"]
[Round "?"]
[White "Rodriguez Cespedes, Amador"]
[Black "Smagin, Sergey"]
[Result "0-1"]
[ECO "C92"]
[WhiteElo "2550"]
[BlackElo "2550"]
[PlyCount "264"]
[EventDate "1988.09.??"]
[EventType "tourn"]
[EventRounds "13"]
[EventCountry "URS"]
[EventCategory "12"]
[Source "ChessBase"]
[SourceDate "1994.03.01"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 O-O 8. c3
d6 9. h3 Be6 10. d4 Bxb3 11. Qxb3 Qb8 12. Bg5 h6 13. Bh4 Qb6 14. dxe5 dxe5 15.
Nbd2 Bc5 16. Nf1 Nh5 17. Qc2 a5 18. N3h2 Ne7 19. Bxe7 Bxe7 20. Ng4 Qe6 21. Qb3
Qxb3 22. axb3 f6 23. g3 Bc5 24. Red1 c6 25. Nfe3 Nxg3 26. fxg3 h5 27. Kg2 hxg4
28. Nxg4 b4 29. Kf3 Rfb8 30. Rab1 Ra7 31. Ke2 a4 32. bxa4 bxc3 33. bxc3 Rxb1
34. Rxb1 Rxa4 35. Kd3 Ra2 36. Kc4 Ba7 37. Rb7 Bg1 38. Rc7 Re2 39. Rxc6 Rxe4+
40. Kd5 Ra4 41. Ke6 e4 42. Kf5 Ra5+ 43. Kf4 g5+ 44. Kxe4 f5+ 45. Kf3 fxg4+ 46.
Kxg4 Kf7 47. Rc4 Bb6 48. h4 gxh4 49. gxh4 Bd8 50. Re4 Bf6 51. c4 Kg6 52. Rf4
Rc5 53. Re4 Be5 54. Kf3 Kh5 55. Rg4 Bf6 56. Kg3 Ra5 57. Re4 Rf5 58. Kh3 Rf3+
59. Kg2 Rc3 60. Kf2 Bxh4+ 61. Ke2 Bg5 62. Rd4 Kg6 63. Rd6+ Kf5 64. Rd5+ Kg4 65.
c5 Bf4 66. c6 Rxc6 67. Kd3 Kf3 68. Rd7 Rc8 69. Kd4 Rc1 70. Rd5 Be3+ 71. Ke5 Rb1
72. Kf5 Rb8 73. Ke5 Rb4 74. Rd1 Rb5+ 75. Ke6 Ke4 76. Re1 Rb6+ 77. Kd7 Kd4 78.
Rd1+ Ke5 79. R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