Repairing same bug over and over again

Discussion of chess software programming and technical issues.

Moderator: Ras

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

Repairing same bug over and over again

Post by Henk »

Thought I already repaired it three times. Some bugs never go away. See endgame.

[pgn]
[Event "Computer Chess Game"]
[Site "HP"]
[Date "2016.05.08"]
[Round "-"]
[White "Fairy-Max 4.8S"]
[Black "SkipperWinb"]
[Result "1/2-1/2"]
[TimeControl "120"]
[Annotator "1. +0.13 1... +0.00"]

1. c4 {+0.13/8} e5 {+0.00/20 2.5} 2. Nc3 {+0.13/8 4} Nf6 {+0.00/17 2.4} 3.
h4 {+0.10/8 4} Nc6 {+0.08/17 2.3} 4. Nf3 {+0.04/9 3} Be7 {+0.03/16 2.3} 5.
d4 {+0.04/9 1.9} exd4 {+0.15/15 2.3} 6. Nxd4 {-0.24/9 2.1} O-O
{+0.16/14 2.3} 7. Nf5 {-0.08/8 1.4} Bb4 {+0.09/14 2.2} 8. a3 {+0.04/9 2.2}
Bxc3+ {+0.80/15 2.2} 9. bxc3 {+0.12/9 2.9} d5 {+0.11/14 2.2} 10. Ne3
{+0.29/10 2.3} dxc4 {+0.21/15 2.0} 11. Qxd8 {+0.20/11 2.0} Rxd8
{+0.23/17 2.1} 12. Nxc4 {+0.19/10 3} Ne4 {+0.23/18 2.0} 13. Bf4
{+0.31/10 2.3} Nxc3 {+0.04/15 1.9} 14. Bxc7 {+0.28/9 1.1} Rd7
{+0.10/17 1.9} 15. Be5 {-0.07/9 1.4} Nxe5 {+0.18/16 1.8} 16. Nxe5
{-0.12/11 3} Rc7 {+0.21/15 1.8} 17. g3 {-0.12/9 1.2} Re7 {+0.21/15 1.8} 18.
Nc4 {-0.22/9 1.7} Be6 {+0.09/14 1.7} 19. Ne3 {+0.00/9 1.3} Nd5
{+0.03/15 1.7} 20. Nc2 {-0.01/10 4} Bg4 {+0.00/14 1.7} 21. Nd4
{+0.07/9 1.0} Rd8 {+0.06/15 2.1} 22. Bh3 {-0.04/8 1.0} Bxe2 {+0.54/15 2.0}
23. Nxe2 {-0.25/9 0.9} Nc3 {+0.45/16 2.1} 24. Bg4 {-0.36/11 3} Rde8
{+0.57/16 1.9} 25. O-O {-0.44/11 2.2} Nxe2+ {+0.67/17 1.8} 26. Kg2
{-0.61/10 8} g6 {+0.65/16 1.8} 27. h5 {-0.49/10 0.9} gxh5 {+0.75/17 1.8}
28. Bxh5 {-0.53/11 1.3} Nd4 {+0.63/15 1.8} 29. Rac1 {-0.48/10 2.6} a5
{+0.53/13 1.6} 30. Rc4 {-0.28/9 0.9} Rd8 {+0.54/16 1.6} 31. Rc5
{-0.25/10 0.9} b6 {+0.56/15 1.6} 32. Rg5+ {-0.25/10 0.8} Kh8 {+0.56/18 1.5}
33. Rd1 {-0.45/10 0.8} f6 {+0.53/15 1.5} 34. Rb5 {-0.35/10 0.7} Rd6
{+0.53/16 1.5} 35. Rb2 {-0.32/11 1.1} f5 {+0.52/15 1.5} 36. Rc1
{-0.30/10 0.6} Kg7 {+0.56/14 1.4} 37. Rc8 {-0.34/9 0.6} b5 {+0.58/14 1.4}
38. Ra8 {-0.33/9 0.9} Kh6 {+0.52/15 1.4} 39. Be8 {-0.19/9 0.9} Re5
{+0.45/16 1.3} 40. Rb8 {+0.12/9 0.9} Rdd5 {+0.47/16 1.3} 41. Rb6+
{+0.25/9 0.8} Kg7 {+0.49/14 0.9} 42. Rb7+ {+0.23/10 1.1} Kf8 {+0.49/16 0.9}
43. Bh5 {+0.14/10 1.1} f4 {+0.54/14 0.9} 44. Rb8+ {+0.01/10 1.5} Kg7
{+0.58/13 0.9} 45. Rb7+ {-0.09/10 1.1} Kh6 {+0.53/14 0.9} 46. Bg4
{-0.27/10 1.3} fxg3 {+0.58/11 0.9} 47. fxg3 {-0.40/10 1.3} Re3
{+0.63/13 1.0} 48. Rb1 {-0.37/9 1.4} Rxa3 {+0.83/9 0.8} 49. Rh1+
{-0.32/9 0.7} Kg6 {+0.58/12 0.7} 50. Rhxh7 {-0.03/9 1.0} Rd8 {+0.63/10 0.8}
51. Rbg7+ {+0.25/8 0.5} Kf6 {+0.65/13 0.7} 52. Rf7+ {+0.22/9 0.5} Ke5
{+0.71/9 0.7} 53. Re7+ {+0.03/9 1.9} Kd6 {+0.70/11 0.7} 54. Rd7+
{-0.12/10 0.6} Rxd7 {+1.06/12 0.6} 55. Rxd7+ {-0.09/10 0.5} Kc5
{+1.20/13 0.7} 56. Rc7+ {-0.37/12 1.0} Kd5 {+1.20/12 0.6} 57. Rd7+
{-0.38/12 1.3} Kc4 {+1.24/14 0.6} 58. Rc7+ {-0.39/12 0.4} Kd3
{+1.22/15 0.6} 59. Bh5 {-0.42/11 0.4} Ra2+ {+1.04/11 0.6} 60. Kh3
{-0.34/12 0.4} b4 {+1.06/13 0.6} 61. Bg6+ {-0.35/13 0.4} Kd2 {+0.63/14 0.6}
62. Rd7 {-0.38/13 0.4} Kc3 {+0.61/13 0.6} 63. Rc7+ {-0.34/13 0.3} Kb2
{+0.74/16 0.6} 64. Rc4 {-0.76/13 0.8} Ne2 {+1.15/14 0.6} 65. Bd3
{-0.80/12 0.5} Ka3 {+1.36/14 0.5} 66. Re4 {-0.92/11 0.5} Nc3 {+1.35/15 0.5}
67. Re5 {-0.97/10 0.3} a4 {+2.02/13 0.5} 68. Rc5 {-1.07/11 0.4} Kb2
{+1.90/15 0.5} 69. Rc6 {-1.07/10 0.5} b3 {+1.35/14 0.5} 70. Rb6
{-1.47/10 0.3} Kc1 {+1.35/15 0.5} 71. Rc6 {-1.50/12 0.4} Rc2 {+1.28/12 0.5}
72. Rf6 {-2.36/10 0.3} a3 {+1.82/11 0.5} 73. Bxc2 {-2.99/11 0.7} bxc2
{+4.64/12 0.5} 74. Rb6 {-5.80/10 0.3} a2 {+6.66/15 0.4} 75. Ra6
{-7.88/12 0.5} Kd1 {+8.89/14 0.4} 76. Rd6+ {-9.97/12 0.2} Ke2
{+9.07/15 0.4} 77. Re6+ {-10.09/11 0.2} Kf2 {+9.09/13 0.4} 78. Rf6+
{-10.22/12 0.5} Kg1 {+9.07/15 0.4} 79. Ra6 {-11.04/11 0.5} c1=Q
{+9.07/10 0.4} 80. Rxa2 {-11.11/11 0.3} Qf1+ {+10.22/9 0.4} 81. Kh4
{-11.10/11 0.3} Nxa2 {+10.12/9 0.4} 82. Kh5 {-11.33/11 0.3} Qh3+
{+11.08/9 0.4} 83. Kg5 {-11.40/12 0.3} Qxg3+ {+11.08/9 0.4} 84. Kf6
{-11.46/11 0.2} Qf2+ {+11.08/8 0.4} 85. Ke5 {-11.49/11 0.2} Kf1
{+11.05/7 0.4} 86. Kd5 {-11.48/11 0.4} Nc3+ {+11.08/7 0.3} 87. Kc4
{-11.47/10 0.2} Ne2 {+11.08/12 0.3} 88. Kd5 {-11.43/11 0.3} Nd4
{+11.07/8 0.3} 89. Ke5 {-11.36/11 0.4} Qb2 {+11.00/8 0.3} 90. Kd5
{-11.30/11 0.3} Qd2 {+11.00/12 0.4} 91. Ke4 {-11.34/11 0.2} Ke1
{+11.00/12 0.3} 92. Ke5 {-11.36/11 0.3} Kf2 {+11.00/8 0.3} 93. Kd5
{-11.36/11 0.5} Kg1 {+11.00/7 0.3} 94. Ke5 {-11.33/11 0.3} Kg2
{+11.00/7 0.3} 95. Ke4 {-11.33/10 0.2} Kh3 {+11.00/12 0.3} 96. Kd5
{-11.34/10 0.2} Kh4 {+11.00/7 0.3} 97. Kd6 {-11.33/10 0.2} Qe2
{+11.00/6 0.3} 98. Kc5 {-11.30/11 0.3} Qf2 {+10.98/9 0.3} 99. Kd5
{-11.30/11 0.3} Qb2 {+11.00/12 0.3} 100. Kc4 {-11.29/10 0.2} Kh3
{+11.00/12 0.3} 101. Kd5 {-11.29/11 0.2} Kg2 {+11.00/12 0.3} 102. Ke4
{-11.31/11 0.5} Kg3 {+11.00/12 0.3} 103. Ke5 {-11.30/11 0.5} Kf3
{+11.00/6 0.3} 104. Kf6 {-11.32/10 0.2} Qc2 {+11.01/7 0.3} 105. Ke5
{-11.32/11 0.3} Ke3 {+11.00/8 0.3} 106. Kf6 {-11.32/10 0.1} Kd2
{+11.00/7 0.3} 107. Ke5 {-11.26/10 0.2} Kd3 {+11.01/7 0.3} 108. Kf6
{-11.30/10 0.2} Qf2+ {+11.01/7 0.3} 109. Kg5 {-11.31/9 0.2} Qa2
{+11.01/7 0.3} 110. Kg6 {-11.29/10 0.2} Kc4 {+11.01/9 0.3} 111. Kf6
{-11.26/9 0.1} Qg2 {+11.01/8 0.3} 112. Kf7 {-11.28/9 0.2} Kd3
{+11.00/7 0.2} 113. Kf6 {-11.30/10 0.1} Ke2 {+11.00/8 0.3} 114. Ke7
{-11.31/10 0.1} Kd2 {+11.00/7 0.2} 115. Kf7 {-11.31/10 0.1} Ke3
{+11.00/9 0.2} 116. Kf6 {-11.32/10 0.1} Kd3 {+11.00/8 0.2} 117. Kf7
{-79.93/11 0.4} Kc3 {+11.00/7 0.3} 118. Kf6 {-11.33/10 0.2} Kb2
{+11.00/7 0.2} 119. Ke5 {-11.36/10 0.2} Qf2 {+10.98/7 0.2} 120. Kd6
{-11.45/10 0.1} Qc2 {+11.01/7 0.2} 121. Ke5 {-11.32/10 0.1} Kc3
{+11.01/8 0.2} 122. Kf6 {-11.42/11 0.3} Qh2 {+11.01/7 0.2} 123. Kg5
{-11.41/10 0.2} Kb2 {+11.00/7 0.2} 124. Kf6 {-11.42/8 0.1} Ka3
{+11.00/6 0.2} 125. Kg5 {-11.36/9 0.1} Kb4 {+11.00/7 0.2} 126. Kf6
{-11.38/10 0.1} Qe2 {+11.00/6 0.2} 127. Kf7 {-79.86/10 0.2} Kc3
{+11.00/8 0.2} 128. Kf6 {-79.91/10 0.1} Kb2 {+11.00/8 0.2} 129. Kf7
{-79.93/10 0.3} Ka3 {+11.00/8 0.2} 130. Kf6 {-79.92/10 0.1} Ka4
{+11.00/7 0.2} 131. Kg6 {-79.89/8 0.1} Qh2 {+11.00/8 0.2} 132. Kf6
{-79.80/10 0.1} Kb5 {+11.00/6 0.2} 133. Ke7 {-11.41/9 0.1} Kc6
{+11.00/6 0.2}
{Xboard adjudication: 50-move rule} 1/2-1/2
[/pgn]
User avatar
hgm
Posts: 28461
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Repairing same bug over and over again

Post by hgm »

So what is the bug here? Perhaps you are 'repairing' the wrong thing.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Repairing same bug over and over again

Post by Henk »

Simpel KQNk endgame. Maybe I have to use table bases to end this loop. Or put all pieces except king and queen in a corner and not allowing them to move. Maybe first make KQk endgame handling perfect.
User avatar
hgm
Posts: 28461
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Repairing same bug over and over again

Post by hgm »

Well, Fairy-Max would have no trouble at all winning this, and it doesn't use tablebases. It could even win this before I made the weights of the centralization table (Fairy-Max' substitute for piece-square tables) tunable on a per-piece basis, and then multiplied that of a bare King (detected in the root) by a factor 5 to 10.

All that is needed is that the eval of a King in a corner is a little worse than that of one in the center, plus the delayed loss bonus. The game you show doesn't seem to have that; there is no attempt at all to drive the bare King towards the corner, although with a Queen this should be totally trivial. There also is no attempt to centralize the own King.
Daniel Anulliero
Posts: 773
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

Re: Repairing same bug over and over again

Post by Daniel Anulliero »

Henk wrote:Simpel KQNk endgame. Maybe I have to use table bases to end this loop. Or put all pieces except king and queen in a corner and not allowing them to move. Maybe first make KQk endgame handling perfect.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Repairing same bug over and over again

Post by Henk »

No. First step: Make sure your code is executed.
flok

Re: Repairing same bug over and over again

Post by flok »

Henk wrote:No. First step: Make sure your code is executed.
I think creating unittests and running them with code coverage checking enabled may help for this.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Repairing same bug over and over again

Post by Henk »

Not to forget: in unittests at least fill hash table with 'normal' values. But maybe that's not possible for what would be 'normal' in that case.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Repairing same bug over and over again

Post by Henk »

Test position should include enough history. Probably only moves of the game where position is from. So test position without game is no test position !? That would mean WAC (Win at Chess) test positions can not be used.
flok

Re: Repairing same bug over and over again

Post by flok »

Henk wrote:Test position should include enough history. Probably only moves of the game where position is from. So test position without game is no test position !? That would mean WAC (Win at Chess) test positions can not be used.
I wonder if WAC may be wrong in some cases.