Stalemate 2017

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Stalemate 2017

Post by Henk »

Already found what went wrong. Wrong value of infinite.

Code: Select all

 
 public const int INFINITE_INT = 1 << 14; // should be 1<<25
[pgn]
[Event "Computer Chess Game"]
[Site "HP"]
[Date "2017.02.05"]
[Round "-"]
[White "Fairy-Max 4.8S"]
[Black "SkipperWinb"]
[Result "1/2-1/2"]
[TimeControl "120"]
[Annotator "1. +0.16 1... +0.40"]

1. c4 {+0.16/8} g6 {+0.40/280 2.0} 2. Nf3 {+0.13/8 1.9} c6 {+0.59/280 2.0}
3. d4 {+0.11/8 3} Qc7 {+1.16/280 2.0} 4. Be3 {-0.02/8 3} Bg7
{+1.26/240 1.9} 5. Nc3 {-0.20/8 2.7} d6 {+1.07/240 1.9} 6. Qa4 {-0.22/8 4}
Nf6 {+0.89/220 1.9} 7. h3 {-0.14/8 4} O-O {+1.09/220 1.8} 8. O-O-O
{+0.07/8 1.7} Rd8 {+1.26/240 1.8} 9. Bf4 {-0.07/7 1.4} Ne8 {+1.32/240 1.8}
10. e4 {-0.07/7 1.9} e6 {+1.25/220 1.8} 11. e5 {-0.09/7 1.9} d5
{+1.32/260 1.7} 12. Bd3 {-0.11/7 1.8} dxc4 {+1.81/260 1.7} 13. Qxc4
{-0.13/8 1.3} b6 {+1.70/220 1.7} 14. Bg5 {-0.09/7 1.2} Rd7 {+1.56/260 1.6}
15. Be4 {-0.03/8 1.7} b5 {+1.82/240 1.6} 16. Qb3 {-0.04/8 1.1} Ba6
{+1.72/200 1.6} 17. Be3 {-0.03/7 1.3} Rd8 {+1.37/200 1.6} 18. a4
{-0.05/8 2.2} bxa4 {+1.82/260 1.5} 19. Qxa4 {-0.16/8 1.7} Rc8
{+1.58/220 1.5} 20. Rde1 {-0.18/6 1.3} Qe7 {+1.50/220 1.5} 21. Qa2
{-0.16/7 1.3} Rc7 {+1.53/200 1.5} 22. Bf4 {-0.09/8 3} Qd7 {+1.46/200 1.4}
23. Qa1 {-0.13/6 1.1} Rb7 {+1.82/240 1.4} 24. Na4 {+0.04/9 1.1} Qc8
{+1.41/240 1.4} 25. Nc5 {+0.19/8 1.1} Rb6 {+1.27/260 1.4} 26. Nxa6
{-0.02/8 1.3} Nxa6 {+1.02/260 1.4} 27. Qa3 {+0.09/7 1.2} Nb4
{+1.34/240 1.3} 28. Nd2 {+0.09/7 1.0} Nd5 {+1.28/220 1.3} 29. Bg3
{+0.03/8 1.0} Bh6 {+1.37/200 1.3} 30. b3 {+0.08/7 0.9} Qb8 {+1.15/220 1.3}
31. Bc2 {+0.03/8 1.2} Nb4 {+1.27/240 1.3} 32. Bb1 {-1.57/9 0.9} Qc7
{+1.31/240 1.2} 33. f4 {+0.27/8 1.9} Nd5 {+1.22/220 1.3} 34. Nc4
{+0.33/7 0.8} Rb4 {+1.35/220 1.2} 35. Rhf1 {+0.24/7 1.4} Rab8
{+1.42/240 1.2} 36. Bc2 {-0.30/7 2.0} g5 {+1.97/240 1.2} 37. Rg1
{-0.43/7 0.9} gxf4 {+2.17/240 1.1} 38. Bf2 {-0.69/7 1.0} Qd7
{+2.22/240 1.1} 39. Qa5 {-0.52/6 0.9} f3+ {+2.57/240 1.1} 40. Nd2
{-0.34/7 1.4} fxg2 {+1.99/260 1.1} 41. Rxg2+ {-0.46/8 1.3} Bg7
{+2.09/240 1.1} 42. Rg3 {-0.38/7 1.5} R4b5 {+2.00/240 1.0} 43. Qa4
{-0.38/8 0.9} Nb4 {+2.01/220 1.0} 44. Bd1 {-0.44/8 1.0} Qc7 {+1.95/220 1.0}
45. Nc4 {-0.42/8 1.5} h6 {+1.08/200 1.0} 46. Reg1 {-0.09/7 0.8} Qd8
{+0.37/200 1.0} 47. Be3 {-0.13/6 0.8} Nd3+ {+0.96/240 1.0} 48. Kb1
{+0.11/5 0.6} Rb4 {+0.98/220 1.0} 49. Qxc6 {+0.43/7 0.7} Rxb3+
{+0.45/260 1.0} 50. Bxb3 {+1.26/8 0.7} Rxb3+ {-0.51/280 0.9} 51. Ka1
{+1.24/7 1.1} Rb4 {-1.27/260 0.9} 52. Na3 {+1.80/7 0.7} Rb3 {-0.84/240 0.9}
53. Qa4 {+2.80/9 1.1} Rb4 {-2.46/260 0.9} 54. Qxa7 {+3.01/9 1.9} Qc8
{-1.92/240 0.9} 55. Bd2 {+3.54/9 0.5} Rb7 {-4.50/260 0.9} 56. Qa5
{+3.85/9 0.7} Nxe5 {-4.69/260 0.9} 57. Qxe5 {+3.91/9 0.9} f6
{-4.86/280 0.9} 58. Qe2 {+3.91/8 1.1} Qd7 {-4.85/260 0.9} 59. Rd3
{+3.78/7 1.0} Kh7 {-4.83/240 0.8} 60. Qh5 {+3.80/7 0.6} f5 {-4.14/260 0.8}
61. Qg6+ {+3.98/7 0.8} Kh8 {-3.97/280 0.8} 62. Be3 {+3.68/7 0.6} f4
{-4.39/220 0.8} 63. Bf2 {+3.58/7 0.5} Nf6 {-3.86/240 0.8} 64. Re1
{+3.70/7 0.5} Rb6 {-3.81/220 0.8} 65. Rf3 {+3.70/7 1.0} Nd5 {-4.05/240 0.8}
66. Re4 {+3.67/7 0.6} Qc6 {-3.74/200 0.7} 67. Re1 {-0.24/8 0.9} Ne3
{+0.47/280 0.7} 68. Qd3 {-0.88/9 0.8} Qxf3 {+1.00/280 0.7} 69. Bxe3
{-1.19/9 0.5} fxe3 {+1.14/280 0.7} 70. Rxe3 {-1.30/9 0.4} Qh1+
{+1.97/320 0.7} 71. Ka2 {-1.26/8 0.4} Qd5+ {+2.05/320 0.7} 72. Qc4
{-1.20/10 0.5} Bxd4 {+2.02/300 0.7} 73. Rb3 {-1.11/10 0.4} Rxb3
{+2.10/300 0.7} 74. Qxb3 {-1.11/10 0.5} Kh7 {+2.12/300 0.7} 75. Qxd5
{-0.95/12 0.4} exd5 {+1.95/400 0.7} 76. Nc2 {-0.92/11 0.4} Be5
{+1.76/380 0.7} 77. Nb4 {-0.66/12 0.5} d4 {+1.76/420 0.7} 78. Kb3
{-0.49/12 0.4} Kg6 {+0.96/400 0.6} 79. Nc6 {-0.66/12 0.4} Kf5
{+1.77/440 0.6} 80. Kc4 {-1.05/12 0.5} Ke4 {+2.07/440 0.6} 81. Nb4
{-1.11/13 0.5} Bf6 {+2.07/420 0.6} 82. Nd3 {-1.08/13 0.5} Kf3
{+2.07/400 0.6} 83. Nb4 {-1.13/12 0.5} h5 {+2.07/400 0.6} 84. Nd5
{-1.09/12 0.4} Bh8 {+2.11/420 0.7} 85. Nc7 {-1.50/12 0.3} Kg3
{+2.45/440 0.6} 86. Nb5 {-1.90/12 0.3} Kxh3 {+2.47/480 0.6} 87. Kd3
{-3.05/12 1.0} h4 {+2.53/440 0.6} 88. Nd6 {-5.75/12 0.4} Kg2
{+6.41/440 0.6} 89. Nf7 {-5.97/13 0.5} h3 {+8.08/440 0.6} 90. Nxh8
{-5.81/14 0.3} h2 {+8.08/460 0.6} 91. Kxd4 {-5.77/13 0.3} h1=Q
{+8.09/420 0.6} 92. Nf7 {-5.89/13 0.7} Kf2 {+8.09/360 0.6} 93. Ne5
{-5.97/11 0.2} Qa1+ {+7.95/360 0.5} 94. Ke4 {-6.02/12 0.3} Qa4+
{+7.95/360 0.6} 95. Kd5 {-6.10/13 0.3} Kg3 {+7.99/340 0.5} 96. Nd3
{-6.06/12 0.3} Qd1 {+7.99/320 0.5} 97. Ke4 {-6.03/12 0.3} Qc2
{+7.98/320 0.5} 98. Kd4 {-6.06/13 0.4} Qc7 {+7.99/360 0.5} 99. Kd5
{-6.04/13 0.4} Qd8+ {+7.99/360 0.5} 100. Ke4 {-6.06/13 0.3} Qa8+
{+7.98/360 0.6} 101. Kd4 {-6.04/13 0.5} Qa7+ {+8.00/340 0.5} 102. Ke4
{-6.04/13 0.3} Qd7 {+8.00/360 0.5} 103. Ne5 {-6.04/13 0.2} Qa4+
{+7.98/360 0.5} 104. Kd5 {-6.09/12 0.2} Kf4 {+8.00/380 0.5} 105. Ng6+
{-6.07/11 0.3} Ke3 {+8.01/360 0.5} 106. Ke5 {-6.07/11 0.3} Kf3
{+8.00/300 0.5} 107. Kf5 {-6.07/11 0.2} Qc2+ {+8.00/320 0.5} 108. Kf6
{-6.07/12 0.2} Qc7 {+7.92/280 0.5} 109. Nf8 {-6.08/12 0.5} Qd6+
{+8.00/300 0.5} 110. Kf7 {-6.07/11 0.2} Kf4 {+8.04/280 0.6} 111. Ke8
{-6.06/11 0.2} Qf6 {+8.04/300 0.5} 112. Nd7 {-6.03/12 0.2} Qe6+
{+8.07/340 0.5} 113. Kd8 {-6.08/13 0.4} Qf7 {+8.05/300 0.5} 114. Kc7
{-6.03/10 0.1} Ke3 {+8.05/300 0.5} 115. Kc6 {-6.05/11 0.1} Qc4+
{+8.05/300 0.5} 116. Kd6 {-6.00/11 0.2} Qd3+ {+8.05/300 0.4} 117. Ke7
{-6.01/11 0.4} Qe4+ {+8.07/300 0.4} 118. Kf7 {-6.05/12 0.3} Qb7
{+8.06/300 0.4} 119. Ke6 {-6.03/12 0.2} Qc6+ {+8.07/340 0.4} 120. Ke7
{-6.06/12 0.2} Kf4 {+8.06/360 0.4} 121. Nf8 {-6.07/11 0.1} Qc7+
{+8.06/320 0.4} 122. Ke6 {-6.07/12 0.2} Kg5 {+8.06/340 0.4} 123. Nd7
{-6.07/12 0.2} Qc6+ {+8.05/320 0.4} 124. Ke7 {-6.15/13 0.3} Kf5
{+8.06/340 0.4} 125. Nf8 {-8.43/13 0.3} Qc4 {+8.06/360 0.4} 126. Ke8
{-8.56/12 0.2} Kf6 {+10.66/360 0.4} 127. Nh7+ {-8.48/11 0.2} Kg7
{+11.70/360 0.4} 128. Ng5 {-8.50/11 0.2} Qb5+ {+11.69/320 0.4} 129. Ke7
{-8.65/11 0.1} Qxg5+ {+11.68/320 0.4} 130. Kd6 {-8.81/12 0.2} Kf6
{+11.52/300 0.4} 131. Kc6 {-79.95/12 0.1} Qa5 {+11.57/320 0.4} 132. Kb7
{-79.95/12 0.1} Qb5+ {+16.38/460 0.5} 133. Ka8 {-79.96/12 0.1} Qb6
{+16.38/260 0.2}
{Xboard adjudication: Stalemate} 1/2-1/2
[/pgn]
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Stalemate 2017

Post by Henk »

Reason why I put infinity to such a small value was to save memory in transposition table a month ago. Set type of Value to 32 bits instead of 64.

But I got for instance mate in 205. So did not work. Also adding random value to evaluation giving not enough variation if range is set too small.
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Stalemate 2017

Post by hgm »

In Fairy-Max INF=8000 works fine, on a centi-Pawn scale. I am not sure what this has to do with stalemate, which should have score 0. And you should not randomize mate scores.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Stalemate 2017

Post by Henk »

hgm wrote:In Fairy-Max INF=8000 works fine, on a centi-Pawn scale. I am not sure what this has to do with stalemate, which should have score 0. And you should not randomize mate scores.
I think Skipper is playing too much the same game. So if random value is scaled down too it might get worse.

Worst thing that might happen is that you test with large number of games but they are almost identical.
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Stalemate 2017

Post by hgm »

This is why you normally test from a variety of start positions or opening lines. Then you have game diversity even with completely deterministic engines.

But that doesn't have anything to do with mating scores. Once a mate is inside the horizon, you don't care if it always performs that mate in the same way. The gameis decided at that time, and what happes after it is irrelevant.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Stalemate 2017

Post by Henk »

hgm wrote:In Fairy-Max INF=8000 works fine, on a centi-Pawn scale. I am not sure what this has to do with stalemate, which should have score 0. And you should not randomize mate scores.
And what would be value of MATE_SCORE. If you compute values n ply below MATE_SCORE it prints them as MATE_IN_<n>. So one must be careful. And you also don't want to lose much precision in evaluation so CENTI_PAWN might be to coarse for how do you evaluate one less in mobility.
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Stalemate 2017

Post by hgm »

Mate in N is INF-N, mated in N is -INF+N. Usually I consider every score s with abs(s) > INF-100 a mate score. I have never seen any of my engines see a mate more distant than 100 moves, and if they did it would be an over-the-horizon mate, as I never allow them to search deeper than 100 ply. And with very deep over-the-horizon mates it isn't really a problem if the mate scores get mutilated by randomization, as they are not even approximately correct.

Fairy-Max doesn't use mobility.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Stalemate 2017

Post by Henk »

hgm wrote:Mate in N is INF-N, mated in N is -INF+N. Usually I consider every score s with abs(s) > INF-100 a mate score. I have never seen any of my engines see a mate more distant than 100 moves, and if they did it would be an over-the-horizon mate, as I never allow them to search deeper than 100 ply. And with very deep over-the-horizon mates it isn't really a problem if the mate scores get mutilated by randomization, as they are not even approximately correct.

Fairy-Max doesn't use mobility.
In Skipper capturing a king is MATE in 0 + 1. King being captured must be greater than -INF otherwise it doesn't update score.
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Stalemate 2017

Post by hgm »

Why do you want it to update the score? It is not a legal move.

In Fairy-Max capturing a King scores +INF. So moves that leave you in check score -INF. Which is also the initial value of bestScore, so it is like the moves were not there at all. Only legal moves have scores > -INF.

If bestMove stays at -INF it knows it has no legal moves. If it is not in check it then corrects the score to 0, for stalemate. Otherwise the score will be less than the current eval, so it will be incremented by 1 before it is returned. Which means in a checkmated position -INF+1 is returned.