Finish end game

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Finish end game

Post by Henk »

Looks like Skipper doesn't know (anymore) how to finish an endgame unless it sees a checkmate. Don't understand why this happens. Maybe because Skipper was in time trouble. What do I need to change to solve this ? Add extra end game knowledge ?

[pgn]

[Event "Computer Chess Game"]
[Site "HP"]
[Date "2014.08.18"]
[Round "-"]
[White "Fairy-Max 4.8S"]
[Black "SkipperWinb"]
[Result "*"]
[TimeControl "120"]
[Annotator "1. +0.09 1... +0.31"]

1. f4 {+0.09/8} Nf6 {+0.31/12 2.4} 2. e3 {+0.11/9 3} Nc6 {+0.24/12 2.4} 3.
Nf3 {+0.23/9 5} a6 {+0.25/11 2.3} 4. Be2 {+0.14/8 1.9} d5 {+0.29/11 2.3} 5.
O-O {+0.18/8 2.1} Bf5 {+0.49/9 2.2} 6. Nc3 {+0.12/8 1.8} Qd6 {+0.41/9 2.2}
7. a4 {-0.13/8 6} e6 {+0.46/8 2.1} 8. Nh4 {+0.15/9 2.2} Bg6 {+0.25/9 2.1}
9. Nxg6 {+0.15/9 1.8} hxg6 {+0.83/10 2.1} 10. d4 {+0.20/9 1.9} g5
{+0.71/9 2.0} 11. Bd2 {+0.18/8 1.8} Be7 {+0.80/8 2.0} 12. h3 {+0.13/8 1.7}
gxf4 {+1.16/10 1.9} 13. Rxf4 {+0.07/8 1.1} O-O-O {+1.15/9 1.9} 14. Rc1
{+0.37/8 2.1} e5 {+1.31/11 1.9} 15. Bg4+ {+0.32/10 2.5} Kb8 {+1.46/10 1.8}
16. dxe5 {+0.04/11 4} Nxe5 {+1.44/10 1.8} 17. Be2 {+0.16/10 2.1} Qc6
{+1.41/8 1.8} 18. Rb1 {+0.18/7 1.2} Ne4 {+1.52/9 1.7} 19. Rf5 {+0.04/7 1.0}
Qe6 {+1.52/9 1.7} 20. Rh5 {-0.07/9 1.2} Rxh5 {+1.94/11 2.0} 21. Bxh5
{-0.69/10 1.3} Nxd2 {+1.64/9 2.0} 22. Qxd2 {-0.79/10 1.2} Nc4 {+1.84/8 2.0}
23. Qf2 {-0.68/9 2.5} g6 {+1.86/9 1.9} 24. Bf3 {-0.75/9 1.3} Nxe3
{+1.99/9 1.9} 25. Na2 {-1.02/8 1.1} d4 {+2.16/9 1.8} 26. b3 {-0.81/8 1.3}
f5 {+2.17/8 1.8} 27. Qe2 {-0.71/7 1.1} g5 {+2.60/8 1.7} 28. Qd3
{-0.74/7 0.8} Bf6 {+2.53/9 1.7} 29. Kf2 {-0.94/8 2.3} g4 {+2.57/8 1.6} 30.
hxg4 {-1.11/7 1.2} fxg4 {+2.64/9 2.1} 31. Qe4 {-1.49/9 1.1} Qc8
{+2.79/10 2.1} 32. Be2 {-1.57/9 1.8} Re8 {+2.68/9 2.0} 33. Qd3
{-1.54/8 0.8} Nd5 {+2.77/9 1.9} 34. g3 {-1.14/8 0.8} Re3 {+2.80/9 1.9} 35.
Qh7 {-1.90/8 1.4} Be5 {+3.45/8 1.8} 36. Rg1 {-2.47/8 1.0} Bxg3+
{+3.47/9 1.7} 37. Rxg3 {-3.49/9 0.9} Qf8+ {+3.41/10 1.7} 38. Rf3
{-3.55/9 2.7} gxf3 {+4.98/10 1.6} 39. Bd3 {-3.57/9 0.8} a5 {+5.01/9 1.6}
40. Qh4 {-3.59/8 0.8} Nf4 {+4.89/9 2.3} 41. Bc4 {-3.58/8 0.8} Qg7
{+4.79/9 2.2} 42. Bf1 {-4.26/9 0.6} Ne2 {+5.28/9 2.0} 43. Qh2
{-6.08/10 1.5} Ka7 {+5.29/9 2.0} 44. c3 {-4.44/9 1.2} Nxc3 {+4.82/11 1.9}
45. Nxc3 {-4.82/10 0.7} Rxc3 {+5.25/10 1.8} 46. Qf4 {-5.13/9 0.6} Rxb3
{+5.67/10 1.7} 47. Qf5 {-5.86/9 0.8} b6 {+5.67/10 1.6} 48. Qc2
{-5.98/10 0.6} Rc3 {+5.73/10 1.5} 49. Qf5 {-6.50/9 0.7} Qg8 {+5.86/9 1.4}
50. Qb5 {-5.93/8 0.6} Qa2+ {+5.84/9 1.4} 51. Kg3 {-6.83/8 0.6} f2+
{+6.02/10 1.3} 52. Kh4 {-7.39/9 0.8} Qc2 {+6.03/9 1.2} 53. Qa6+
{-6.99/10 0.6} Kb8 {+6.25/12 1.2} 54. Qe2 {-11.16/10 1.3} Qxe2
{+6.40/13 1.1} 55. Bxe2 {-13.99/14 0.6} Re3 {+6.48/11 1.0} 56. Bf1
{-17.04/15 1.2} c6 {+6.67/11 1.0} 57. Kg5 {-10.33/15 0.5} Kc7
{+6.72/11 1.0} 58. Kf4 {-7.35/16 0.6} Re1 {+8.63/11 0.9} 59. Bc4
{-7.44/16 1.2} f1=Q+ {+9.05/15 0.9} 60. Bxf1 {-8.06/12 0.6} Rxf1+
{+8.98/14 0.8} 61. Ke4 {-9.93/13 0.9} c5 {+9.17/13 0.8} 62. Kd3
{-8.86/12 0.5} Ra1 {+9.25/13 0.8} 63. Kd2 {-9.55/12 0.4} Rxa4
{+9.25/15 0.7} 64. Kd3 {-15.22/13 0.6} Kd6 {+9.25/14 0.7} 65. Ke4
{-15.25/13 0.6} b5 {+9.63/14 0.6} 66. Kd3 {-15.88/12 0.5} Rc4
{+9.75/14 0.6} 67. Ke4 {-16.01/14 1.1} b4 {+9.84/15 0.6} 68. Kd3
{-22.96/14 1.1} Rc3+ {+9.98/14 0.5} 69. Ke4 {-79.94/14 0.9} Re3+
{+10.20/14 0.5} 70. Kf5 {-18.65/12 0.4} c4 {+10.31/14 0.5} 71. Kf4
{-22.89/12 0.4} c3 {+11.02/15 0.5} 72. Kg4 {-23.56/12 0.6} c2
{+10.42/13 0.4} 73. Kh4 {-79.96/11 0.7} d3 {+10.49/12 0.4} 74. Kh5
{-79.96/11 0.3} d2 {+10.99/12 0.4} 75. Kg4 {-79.96/11 0.3} b3
{+10.96/11 0.4} 76. Kf4 {-79.96/12 0.3} Rc3 {+10.98/11 0.4} 77. Kf5
{-79.96/11 0.3} b2 {+11.68/11 0.3} 78. Kg5 {-79.96/10 0.5} a4
{+11.68/11 0.3} 79. Kf6 {-31.25/9 0.2} a3 {+11.67/11 0.3} 80. Kf5
{-38.38/10 0.5} a2 {+11.67/11 0.3} 81. Kg5 {-79.96/10 0.3} Ke5
{+11.67/11 0.3} 82. Kg6 {-38.47/9 0.2} Kd5 {+11.69/11 0.3} 83. Kf6
{-79.94/10 1.0} Kd4 {+11.68/10 0.3} 84. Kf5 {-38.42/10 0.5} Ra3
{+11.68/11 0.3} 85. Kg5 {-79.94/10 0.9} Ke5 {+11.69/12 0.2} 86. Kg6
{-79.96/10 0.2} Rh3 {+11.66/10 0.2} 87. Kg7 {-79.96/11 0.2} Kd5
{+11.67/10 0.2} 88. Kf6 {-79.94/10 0.7} Ra3 {+11.66/10 0.2} 89. Kf7
{-79.96/10 0.3} Rg3 {+11.68/10 0.2} 90. Kf6 {-79.96/10 0.3} Kd4
{+11.68/10 0.2} 91. Ke6 {-79.96/11 0.2} Ra3 {+11.68/9 0.2} 92. Kf5
{-79.94/10 0.2} Kd5 {+11.68/10 0.2} 93. Kf6 {-79.95/10 0.2} Ke4
{+11.68/10 0.2} 94. Kf7 {-79.96/10 0.9} Kd4 {+11.68/10 0.2} 95. Ke6
{-79.94/10 0.4} Rh3 {+11.69/9 0.2} 96. Ke7 {-79.94/10 0.4} Rb3
{+11.69/10 0.1} 97. Ke6 {-79.95/10 0.5} Rg3 {+11.67/9 0.1} 98. Kd7
{-79.96/10 0.2} Kd5 {+11.67/10 0.1} 99. Ke7 {-79.96/10 0.1} Rb3
{+11.66/9 0.1} 100. Kf6 {-79.95/10 0.3} Ke4 {+11.67/9 0.1} 101. Ke6
{-38.42/9 0.1} Rh3 {+11.68/9 0.1} 102. Kf6 {-79.95/9 0.2} Kd5
{+11.67/9 0.1} 103. Kf5 {-79.95/9 0.1} Rd3 {+11.68/10 0.1} 104. Kf6
{-79.95/10 0.5} Kd4 {+11.68/10 0.1} 105. Ke6 {-79.92/9 0.1} Rb3
{+11.67/9 0.1} 106. Kf5 {-79.94/10 0.3} Rh3 {+11.65/8 0.1} 107. Kg4
{-38.41/9 0.2} Rd3 {+11.68/10 0.1}

[/pgn]
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Finish end game

Post by mar »

Henk wrote:What do I need to change to solve this ?
Teach Skipper how to promote pawns.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Finish end game

Post by Henk »

It knows how to promote pawns. I played another game and it finished the game by promoting into a queen. But perhaps he did that for he saw a checkmate.

Or he delays all promotions or perhaps he doesn't see that promotions give an advantage.

I also saw that he delays winning captures. For the capture can as well be done a move later. Maybe that's the same situation.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Finish end game

Post by mar »

Henk wrote:It knows how to promote pawns. I played another game and it finished the game by promoting into a queen. But perhaps he did that for he saw a checkmate.

Or he delays all promotions or perhaps he doesn't see that promotions give an advantage.

I also saw that he delays winning captures. For the capture can as well be done a move later. Maybe that's the same situation.
Hmm... I don't see a reason to delay the promotion of a pawn in such position.
Even a pure material engine would do that yet skipper shows +11.68, so it can't value advanced passer more than a queen.
Were it my code, I would look for bugs (like do I really update material after promotion? etc...)
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Finish end game

Post by Henk »

Ok you're right I changed the material computer recently. So I have to look there.

I already see what goes wrong. I add the queen to BlackPieces but not to the BlackQueens list and material score computer uses BlackQueens. For I changed that a few days ago.

Ok solved I guess.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Finish end game

Post by Henk »

Fixing the bug made it play much worse. To overcome this I only generate promotion moves if GamePhase > 0.5 and now I finally have a winner. But this solution looks like rubbish.


[pgn]
[Event "Computer Chess Game"]
[Site "HP"]
[Date "2014.08.18"]
[Round "-"]
[White "Fairy-Max 4.8S"]
[Black "SkipperWinb"]
[Result "0-1"]
[TimeControl "120"]
[Annotator "1. +0.19 1... -0.12"]

1. d4 {+0.19/9} Nf6 {-0.12/10 2.4} 2. Bf4 {+0.13/8 3} d5 {-0.04/9 2.4} 3.
c3 {+0.19/8 8} Nc6 {+0.30/10 2.3} 4. Nd2 {+0.09/8 3} Bf5 {+0.28/9 2.3} 5.
Qb3 {+0.09/8 6} Rb8 {+0.30/9 2.2} 6. O-O-O {+0.17/8 3} Ng4 {+0.79/9 2.2} 7.
Nh3 {+0.05/7 1.4} e6 {+0.74/9 2.1} 8. f3 {+0.03/8 2.1} Nf6 {+0.50/9 2.1} 9.
g4 {+0.01/8 1.6} Bg6 {+0.75/9 2.0} 10. Bg5 {-0.07/8 1.7} h6 {+0.82/9 2.0}
11. Be3 {-0.11/9 2.9} b5 {+0.89/8 2.0} 12. Re1 {-0.01/8 1.1} Na5
{+0.70/9 1.9} 13. Qd1 {-0.04/9 1.1} Bd6 {+0.45/10 1.9} 14. Nf4
{-0.10/9 1.6} Nc4 {+0.27/10 1.9} 15. Nxc4 {+0.20/10 0.9} Bxf4
{-0.04/10 1.8} 16. Bxf4 {+0.15/10 2.0} bxc4 {+0.13/9 1.8} 17. Qa4+
{+1.02/9 1.0} Qd7 {-0.02/10 1.8} 18. Qxa7 {+0.84/9 1.2} O-O {-0.09/9 1.7}
19. e3 {+1.00/8 1.5} Qb5 {+0.30/8 1.7} 20. Re2 {+1.09/7 1.0} Bd3
{+0.10/9 2.0} 21. Rg2 {+1.11/8 1.4} Ra8 {-0.03/9 2.0} 22. Qxc7
{+0.41/9 1.0} Rxa2 {+0.47/10 2.0} 23. Bxd3 {-2.42/9 1.0} cxd3 {+0.44/9 1.9}
24. Bd6 {-4.22/9 3} Ra1+ {+5.30/10 1.9} 25. Kd2 {-7.22/9 0.9} Rxh1
{+5.36/10 1.8} 26. Bb4 {-11.36/10 2.9} Rb1 {+5.38/9 1.8} 27. Qg3
{-5.05/9 1.5} Rxb2+ {+6.25/11 1.7} 28. Kc1 {-5.00/8 0.9} Rxg2
{+6.02/10 1.7} 29. Qxg2 {-4.77/11 1.0} Ra8 {+5.97/8 1.6} 30. Qb2
{-4.88/9 0.7} Qc4 {+6.12/8 2.1} 31. Ba3 {-5.26/9 1.0} Rc8 {+6.11/9 2.1} 32.
Kd2 {-4.69/9 1.6} Nd7 {+5.67/9 2.0} 33. h3 {-4.66/8 1.0} Nb6 {+5.78/9 1.9}
34. Ke1 {-6.24/9 1.4} Qxc3+ {+6.31/8 1.9} 35. Qxc3 {-7.60/12 1.2} Rxc3
{+7.04/10 1.8} 36. Bb4 {-8.15/13 0.9} Rc2 {+6.79/10 1.7} 37. e4
{-6.80/12 1.0} dxe4 {+7.20/12 1.7} 38. fxe4 {-7.49/12 0.9} Re2+
{+6.96/10 1.6} 39. Kf1 {-8.36/13 0.6} Rxe4 {+7.61/10 1.6} 40. Kf2
{-8.40/13 1.2} Nd5 {+7.99/9 2.3} 41. Ba5 {-8.33/13 0.6} Rxd4 {+7.96/10 2.2}
42. Ke1 {-7.60/12 0.6} g5 {+8.04/10 2.0} 43. Bd2 {-7.75/14 0.5} e5
{+8.14/11 2.0} 44. h4 {-9.23/13 0.5} Rxg4 {+9.26/11 1.9} 45. hxg5
{-9.09/14 0.8} hxg5 {+9.29/12 1.8} 46. Kf1 {-10.03/15 1.2} f5
{+9.27/11 1.7} 47. Kf2 {-11.22/15 0.6} f4 {+9.56/11 1.6} 48. Kf3
{-11.03/16 0.8} Nf6 {+9.63/10 1.5} 49. Kf2 {-16.87/17 0.6} Rg3
{+9.55/10 1.4} 50. Kf1 {-18.20/15 0.6} Ne4 {+9.82/9 1.4} 51. Bc1
{-79.94/16 0.4} Re3 {+12.36/11 1.3} 52. Kg2 {-16.57/14 0.5} d2
{+11.70/11 1.2} 53. Bxd2 {-16.54/16 0.4} Nxd2 {+11.85/14 1.2} 54. Kf2
{-79.95/12 0.5} Rg3 {+11.80/13 1.1} 55. Ke1 {-79.92/13 1.0} Ne4
{+11.77/13 1.1} 56. Ke2 {-79.95/13 0.5} f3+ {+15.59/13 1.0} 57. Ke3
{-21.79/13 1.4} f2+ {+15.59/14 1.0} 58. Kxe4 {-22.00/12 0.7} f1=Q
{+15.67/13 0.9} 59. Kd5 {-79.96/11 0.5} Qf4 {+16.70/12 0.9} 60. Kc5
{-79.96/12 0.5} Qd4+ {+16.73/13 0.8} 61. Kc6 {-79.96/11 0.4} Kf7
{+24.80/13 0.8} 62. Kc7 {-79.97/15 0.5} Qc4+ {+1999.90/12 0.7} 63. Kd6
{-79.98/28 0.2} Rd3+ {+1999.93/11 0.7} 64. Kxe5 {-79.99/28 0.2} Qb5+
{+1999.91/13 0.7} 65. Ke4 {-79.99/28 0.2} Qd5# {+1999.90/12 0.6}
{Xboard adjudication: Checkmate} 0-1
[/pgn]
PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Finish end game

Post by PK »

Forget fixing bugs by introducing bugs, this is a road to nowhere! If Your engine plays worse after fixing something as basic as updating material values, then either You haven't fixed it properly or there's another bug to be found.

Before You go any further, I'd suggest the following: create a debug routine that calculates from scratch everything that Your engine updates incrementally. Let the routine remember pre-move and post-move state. Run it after EVERY move and let it print the board and the move if there is a mismatch. Your goal should be to play a couple of hundreds of games without any error output from that routine. Only then You should begin to worry about strength.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Finish end game

Post by Henk »

After that fix yesterday everything worked fine accept the performance. Promotions were working fine. To speed it up I thought it would be best not to generate promotion moves in first half of the game for they normally make no sense. Perhaps I should remove that change.


Unfortunately I'm in trouble again when I started to optimize killer moves.
I changed much too much. I think I restore a backup and stop and restart another time.

So I would say to myself do something useful do nothing and quit.
PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Finish end game

Post by PK »

Henk wrote:To speed it up I thought it would be best not to generate promotion moves in first half of the game for they normally make no sense.
[pgn]
1.e4 b6 2.d4 Bb7 3.Bd3 f5 4.exf5 Bxg2 5.Qh5+ g6 6.fxg6 Bg7 7.gxh7 Kf8 8.fxg7=R+
[/pgn]

Ok, I admit that 8.Nf3 is better, but the engine should be able to check it for itself. So let's look at something more serious, namely The Lasker Trap:

[pgn]
1.d4 d5 2.c4 e5 3.dxe5 d4 4.e3? Bb4+ 5.Bd2 dxe3! 6.Bxb4?? exf2+! 7.Ke2 fxg1=N+!
[/pgn]

And now Casper - Heckert, GDR 1975:

[pgn]
1.e4 Nf6 2.Nc3 d5 3.e5 d4 4.exf6 dxc3 5.d4 cxb2 6.fxg7 bxa1=Q 7.gxh8=Q
[/pgn]
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Finish end game

Post by Henk »

And what about these SEE in qSearch, removing bad captures. That's rubbish too for we don't know if it is really a bad capture. But everybody seems to use it for it gives some ELO points.