Playing the endgame like a boss !!

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

jp
Posts: 1470
Joined: Mon Apr 23, 2018 7:54 am

Re: Playing the endgame like a boss !!

Post by jp »

Eduard wrote: Fri Mar 15, 2019 8:35 am I've seen on chess.com how leela checkmated with the queen and also with knight and bishop. But always before the 50. move. The problem must therefore be related to this 50. moves rule.
Yeah, it's interesting that it converted KRvK in exactly 49 moves.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Playing the endgame like a boss !!

Post by hgm »

An example from the monthly blitz where it is not so lucky to diffuse into a winning conversion, while aimlessly moving from one 'certain win' to another...

[pgn][Event "ICS Rated blitz match"] [Site "winboard.nl"] [Date "2019.03.16"] [Round "-"] [White "LeelaRB"] [Black "Marvin"] [Result "1/2-1/2"] [WhiteElo "2027"] [BlackElo "1817"] [TimeControl "300+1"] 1. d4 Nf6 2. c4 e6 3. Nf3 d5 4. g3 Be7 5. Bg2 O-O 6. O-O dxc4 7. Qc2 a6 8. Qxc4 b5 9. Qc2 Bb7 10. Bg5 Nbd7 11. Bxf6 Nxf6 12. Nbd2 Rc8 13. Nb3 Be4 14. Qc3 Qd5 15. Rfc1 Rfd8 16. Nbd2 c5 17. e3 Bg6 18. Qa5 Qd6 19. Rxc5 Rxc5 20. dxc5 Qxc5 21. Nd4 Qb4 22. N2b3 Qxa5 23. Nxa5 Bf8 24. Nac6 Re8 25. a4 b4 26. Ne5 Be4 27. Rc1 Rd8 28. Nec6 Rd5 29. Bf1 e5 30. f3 Bg6 31. Nb3 Nd7 32. Bxa6 Nc5 33. Nxc5 Bxc5 34. Kf1 Bxe3 35. Re1 Bc5 36. Bc4 Rd6 37. Nxe5 Kf8 38. Nxg6+ hxg6 39. b3 Rd2 40. Re5 Ba7 41. Rb5 f5 42. Rb7 Be3 43. a5 Rxh2 44. a6 Rf2+ 45. Ke1 Rxf3 46. a7 Bxa7 47. Rxa7 Rxg3 48. Rf7+ Ke8 49. Kf2 Rg4 50. Rxg7 g5 51. Ke3 {+12.61/9} Kd8 52. Bd5 {+17.29/7} Ke8 53. Kd3 {+16.11/7} Kf8 54. Rf7+ {+28.57/7} Ke8 55. Rxf5 {+49.06/7} Kd8 56. Rf7 {+54.65/6} Ke8 57. Rg7 {+51.00/6} Kf8 58. Rg6 {+51.16/6} Ke7 59. Ke3 {+49.56/6} Rg1 60. Kd4 {+59.22/5} Kd7 61. Rf6 {+57.72/5} Ke7 62. Rf5 {+55.18/6} Kd6 63. Bc4 {+48.77/5} Rg4+ 64. Ke3 {+56.04/6} Rg2 65. Kf3 {+56.68/6} Rg1 66. Kf2 {+51.68/5} Rg4 67. Be2 {+46.36/5} Re4 68. Rxg5 {+62.25/5} Ke7 69. Rh5 {+60.02/4} Kf8 70. Rh8+ {+61.36/4} Kg7 71. Rh2 {+62.40/6} Re7 72. Rh4 {+49.33/4} Rb7 73. Rg4+ {+24.59/5} Kf6 74. Rg3 {+44.54/4} Rb6 75. Rg2 {+38.70/4} Rc6 76. Rg1 {+46.58/5} Rb6 77. Rf1 {+35.54/4} Ke7 78. Re1 {+41.93/4} Kd6 79. Rd1+ {+34.75/4} Ke5 80. Kf3 {+51.95/4} Rh6 81. Bc4 {+52.43/4} Rh3+ 82. Kg4 {+47.43/5} Rh2 83. Kg3 {+42.24/4} Rh8 84. Re1+ {+46.86/4} Kd4 85. Rf1 {+41.15/4} Kc3 86. Rf3+ {+41.61/4} Kb2 87. Kf4 {+41.54/4} Re8 88. Rh3 {+45.90/4} Re1 89. Kf5 {+38.36/4} Re8 90. Kf6 {+39.99/4} Re1 91. Rg3 {+34.74/4} Ka3 92. Kf5 {+27.89/4} Kb2 93. Kf4 {+21.20/4} Ka3 94. Re3 {+28.92/4} Rh1 95. Ke4 {+37.00/4} Rh6 96. Kd5 {+35.97/4} Rh8 97. Rf3 {+33.34/4} Rd8+ 98. Ke6 {+34.09/5} Rh8 99. Kd7 {+29.97/4} Rh6 100. Re3 {+31.69/4} Rh5 101. Kc6 {+25.97/4} Ra5 102. Kb6 {+27.63/5} Rg5 103. Ka6 {+22.55/4} Rc5 104. Re7 {+31.19/4} Rg5 105. Kb6 {+26.60/5} Kb2 106. Re8 {+22.72/4} Rh5 107. Rg8 {+23.30/4} Rf5 108. Rh8 {+21.87/5} Re5 109. Rh7 {+20.39/5} Rf5 110. Rh6 {+15.39/5} Kc3 111. Ka6 {+18.44/4} Kb2 112. Rd6 {+11.34/5} Rh5 113. Rd5 {+6.53/4} Rh1 114. Ra5 {+6.34/5} Rh7 115. Rg5 {+1.85/5} Kc3 116. Bg8 {+0.89/4} Rh6+ 117. Ka5 {+0.07/4} Rh4 118. Rg3+ {+0.00/2} {Game drawn by the 50 move rule} 1/2-1/2 [/pgn]
User avatar
M ANSARI
Posts: 3707
Joined: Thu Mar 16, 2006 7:10 pm

Re: Playing the endgame like a boss !!

Post by M ANSARI »

hgm wrote: Fri Mar 15, 2019 1:36 pm The problem with that is that when you do not know how to convert 'certain wins', they suddenly become a lot less certain...

Your statement also bypasses the fact that win probabilities as determined by the NN are not infinitely accurate, but are necessarily polluted by a great deal of noise. So in practice, if you have the choice between going for an estimated win probability of 90.1% with estimated remaining game length of 20 moves, and an estimated win probability of 90.0% with estimated remaining length of 50, when the estimation noise is 3%, it would be really foolish to go for the 50 moves like that extra 0.1% is real. The estimated remaining length is likely a much more reliable indicator for whether you are dealing with a 90%+3% case rather than a 90.1%-3% case.

So what I am basically saying is that witholding the duration info from the NN during training will severely degrade the accuracy with which it can eventually estimate the win probabilities. And taking the theoretically best decision based on compromised data will in practice often lead to the wrong decision. When game length had been folded into the reward function during training, the NN would, in the example above, probably not have said 90.1% vs 90% +/- 3%, but 88% vs 92% +/- 1%. And that would enable it to go for what is the highest win probability in reality, rather than the imagined one based on inaccuracy.
Actually that is a very good point! There must be ways to fix it in the way the engine is trained. Very ironic as that is what AI is all about. Maybe it is time to start thinking of a more "correct" training scheme and maybe there are parameters that can be added to its training that can teach it to stop this nonsense.
User avatar
M ANSARI
Posts: 3707
Joined: Thu Mar 16, 2006 7:10 pm

Re: Playing the endgame like a boss !!

Post by M ANSARI »

Double Post Again
Uri Blass
Posts: 10269
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Playing the endgame like a boss !!

Post by Uri Blass »

hgm wrote: Fri Mar 15, 2019 9:07 am
mwyoung wrote: Fri Mar 15, 2019 5:06 amI have seen Lc0 play in a style where it does not care how long it takes to mate. As long as it wins. And this makes perfect sense if your learned the game from ZERO. And all that matters is wins and losses and draw. You get no bonus for finding the shortest win.

To fix this issue. I don't know if you could call Lc0. Zero any more.
I don't agree. In any game a faster win is preferable over a slower win. That is not domain-specific knowledge any more than that a win is preferable over a loss. It is not enough to know how to reach a position from which you theoretically can force a win if you do not know how to actually convert it. You have to train gae-playing entities how to make progress towards a win, especially in the Zero approach.

LC0 is just trained for the wrong thing. And it is likely this very much slows down its training, as in many of its training examples it will not be able to recognize it did something good because its inability to convert the won position will mask it.
Not in any game a faster win is preferable.
For example I can define chessX to have the same rules like chess except that the winner get (n-1)/n points and the loser get 1/n points when n is the number of moves in the game.

In chessX it is clear that a slower win is better.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Playing the endgame like a boss !!

Post by hgm »

You are of course right in that case, although it is debatable whether a win is truly a win if it doesn't achieve an all-vs-nothing score. I was thinking of games with a binary result, plus perhaps a draw. Things can be very different in games where the goal is to collect points, especially if the score is made explicitly dependent on the game duration.

But I would still not consider that domain-specific knowledge; the scoring system is part of the game rules. And when the scoring depends on duration, it would be even more detrimental to not use the game duration or the actual score during training, but only tell the NN if it got more points than the opponent.

Anyway, a performance like the one I posted is rather embarrassing.
jp
Posts: 1470
Joined: Mon Apr 23, 2018 7:54 am

Re: Playing the endgame like a boss !!

Post by jp »

jp wrote: Fri Mar 15, 2019 4:22 pm
Eduard wrote: Fri Mar 15, 2019 8:35 am I've seen on chess.com how leela checkmated with the queen and also with knight and bishop. But always before the 50. move. The problem must therefore be related to this 50. moves rule.
Yeah, it's interesting that it converted KRvK in exactly 49 moves.
I think there was another 49 move conversion today near the end of ccc6...
Alexander Lim
Posts: 43
Joined: Sun Mar 10, 2019 1:16 am
Full name: Alexander Lim

Re: Playing the endgame like a boss !!

Post by Alexander Lim »

One of the problems so far is we haven't been able to compare Leela's endgame play with another NN engine. Is it an issue with the value head, policy head, MCTS or the training process? Chess Fighter uses all of the above and doesn't display any such issues.

First of all here is CF's continuation after 120. ... Ke3:

[pgn][Event "Computer chess game"] [Site "DESKTOP-8549RR7"] [Date "2019.03.15"] [Round "?"] [White "Chess Fighter (net 14175)"] [Black "Stockfish_10"] [Result "*"] [BlackElo "3400"] [Time "08:53:31"] [WhiteElo "2500"] [TimeControl "120+3"] [SetUp "1"] [FEN "1K6/8/3B2p1/8/8/4k2P/6P1/8 w - - 0 1"] [Termination "normal"] [PlyCount "41"] [WhiteType "human"] [BlackType "human"] 1. h4 {+5.52/25 7} Ke4 {(Ke3-e4 Kb8-c7 Ke4-f5 g2-g3 Kf5-e6 g3-g4 Ke6-f7 Kc7-d7 Kf7-f6 Bd6-b8 g6-g5 h4-h5 Kf6-f7 Bb8-g3 Kf7-f8 Bg3-d6+ Kf8-f7 Bd6-e7 Kf7-g8 Kd7-e6 Kg8-g7 Be7xg5 Kg7-g8 Ke6-e7 Kg8-g7 h5-h6+ Kg7-g6 Bg5-f4 Kg6-h7 Ke7-f7 Kh7-h8 g4-g5 Kh8-h7 g5-g6+ Kh7-h8 Bf4-e5+) -M18/44 8} 2. g4 {+6.33/23 6} Kd5 {(Ke4-d5 Kb8-c7 Kd5-e6 Kc7-c6 Ke6-f7 Kc6-d7 Kf7-f6 Bd6-c7 g6-g5 h4-h5 Kf6-f7 Bc7-d8 Kf7-g7 Kd7-e6 Kg7-f8 Bd8-f6 Kf8-g8 h5-h6 Kg8-h7 Bf6xg5 Kh7-g6 Bg5-f4 Kg6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.99/14 5} Kc5 {(Kc4-c5) -M2/1} 20. Bf8+ {+10.00/13 5} Kc4 {(Kc5-c4) -M1/1} 21. Qb4# {+9.98/14 4} * [/pgn]

(Looks like I entered the position incorrectly but it shouldn't affect the conclusions of this post)

CF's evaluation ranges from -1 to 1 from which I multiply by 10 to get a display output from -10 to 10 where 10 == white win.

There are two phases to analyse here:

Stage 1: From move 1 to 16 the NN is guiding the game gradually towards a position where mate is likely. Notice the gradual increase in evaluation from +5.52 to +9.21. The game is definitely winning for white but not yet won and CF knows this.

Stage 2: On move 17 there is a sudden jump in evaluation from +9.21 to +9.96. This means CF has now 'seen' mate and without fail the MCTS algorithm converges onto the mate 4 moves later.

Now for Leela:

Stage 1: This lasts roughly from move 120 to move 234 (114 moves!). Using a 6x64 Leela net most its the evals hover around 95% (+9.75 using CF scale). The problem is this is too high and together with noise there is just not enough wiggle room for the eval climb towards a mating position. It also seems the position at move 234 was the result of random shuffling and/or threat of 50 move rule.

Stage 2: Actually this part is fine. Though it's not clear if it was the threat of a 50-move rule that forced Leela play the mate or not. Does Leela still troll around mating positions?

I think most people already know the problem is the Leela evals are saturated around 95%-100% so I've not said anything new there. But the question is why? One thing I thought was that Leela's played so many millions of games that the evals of winning positions will eventually all converge to the extremes. If that's the case then CF's eval should go to +1 also. Here are CF's eval for various generations after 120. ... Ke3:

Scale from -1 to 1. The first number is the static eval of the position, second is the average of a 10,000 node search.

gen 2000 0.38/0.38
gen 4000 0.44/0.41
gen 6000 0.62/0.57
gen 8000 0.55/0.46
gen 10000 0.60/0.54
gen 12000 0.55/0.51
gen 14000 0.51/0.47

Although we're only talking of 100,000's of self-play games (and not millions) it looks like it's stabilising around +0.5 which I think is key to getting aesthetically pleasing endgames.

Apparently Demis Hassabis said AlphaZero does not suffer from these endgame problems (One of the Leela developers mentions this on a youbtube video). Are there any AlphaZero games played to the endgame with mate to confirm this?

Out of the three main stages: Opening, middle-game and endgame it seems most people (judging by the forum posts) are resigned to the fact that NN engines just wont ever play the endgame (the Ender project only plays the endgame). I really don't think that's the case. The NN engines will eventually dominate on all stages of the game and I'm sure they will have something to teach us on the endgame as well.

I also think they will eventually conquer the tactics arena at some stage though that will probably require radically new algorithms and network structures.

For now there's only one NN who plays the endgame like a boss, and it's not Leela! :wink:

To finish off here is CF's continuation of the Leela-Marvin game after 51. ... Kd8. Note the gradual increase in eval (mate is seen on move 34).

[pgn][Event "Computer chess game"] [Site "DESKTOP-8549RR7"] [Date "2019.03.16"] [Round "?"] [White "Chess Fighter (net 15800)"] [Black "Stockfish_10_x64"] [Result "1-0"] [BlackElo "3400"] [Time "22:38:15"] [WhiteElo "2500"] [TimeControl "120+3"] [SetUp "1"] [FEN "3k4/6R1/8/5pp1/1pB3r1/1P2K3/8/8 w - - 0 1"] [Termination "normal"] [PlyCount "77"] [WhiteType "human"] [BlackType "human"] 1. Bd5 {+2.75/19 7} Ke8 {(Kd8-e8 Ke3-d3 Ke8-f8 Rg7-f7+ Kf8-g8 Rf7xf5+ Kg8-g7 Bd5-c4 Rg4-g1 Kd3-e4 Rg1-g4+ Ke4-f3 Rg4-g1 Kf3-f2 Kg7-g6 Rf5-b5 Rg1-h1 Kf2-f3 Kg6-f6 Rb5xb4 Rh1-h3+ Kf3-g4 Rh3-h4+ Kg4-g3 Kf6-e5 Rb4-b5+ Ke5-d4 Rb5xg5 Rh4-e4 Rg5-g8 Kd4-c3 Kg3-f3 Re4-h4 Rg8-g5 Rh4-h8 Kf3-f4 Rh8-e8 Kf4-f5 Re8-f8+ Kf5-e5 Rf8-e8+ Ke5-d6 Re8-d8+ Kd6-c7 Rd8-f8) -3.75/29 6} 2. Kd3 {+2.82/20 6} Kf8 {(Ke8-f8 Rg7-f7+ Kf8-e8 Rf7xf5 Ke8-e7 Bd5-c4 Ke7-d6 Rf5-d5+ Kd6-c6 Rd5-b5 Rg4-g3+ Kd3-d4 Rg3-g4+ Kd4-e5 Rg4-h4 Rb5xb4 g5-g4 Bc4-e2 Rh4-h5+ Ke5-f4 Rh5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15 4} Kc2 {(Kd2-c2 Qa3-b4 Kc2-c1 Bb5-d3 Kc1-d1 Qb4-b2 Kd1-e1 Qb2-e2+) -M4/120 1} 36. Ke5 {+9.99/15 4} Kd2 {(Kc2-d2 Qa3-b2+ Kd2-d1 Ke5-d4 Kd1-e1 Qb2-e2+) -M3/127} 37. Qb2+ {+9.99/13 4} Kd1 {(Kd2-d1 Ke5-d4 Kd1-e1 Qb2-e2+) -M2/127} 38. Bf1 {+9.99/12 4} Ke1 {(Kd1-e1) -M1/1} 39. Qe2# {+9.99/11 4} 1-0 [/pgn]

Alex
Alexander Lim
Posts: 43
Joined: Sun Mar 10, 2019 1:16 am
Full name: Alexander Lim

Re: Playing the endgame like a boss !!

Post by Alexander Lim »

By the way, the purpose of my previous post (aside from showing off Chess Fighters amazing endgame prowess :wink: ) was to illustrate that Leela's naughty endgame / trolling behaviour is not an inherent problem of NN's or MCTS. It's just... well... Leela!
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Playing the endgame like a boss !!

Post by hgm »

Of course it is not an intrinsic NN problem. The evaluation you need to swiftly win KRK even with a very shallow search is extremely simple (centralization bonus for the Kings, somewhat larger for the bare one, through PST will already do). A NN as complex as that of Leela can very easily calculate that function in its value head, and the policy head would hardly matter in cases where a two-ply search is already sufficient. Besides, you cannot expect miracles from the policy head: it is trained to guide the search towards a high evaluation from the value head, and if the latter is always a certain win, the policy head won't care what you play.

But when you train the net to ignore the difference between low DTM and high DTM, insisting that the value head should deliver 100.0% all the time, because any KRK position with the strong side to move is a certain win, you make it impossible for the engine to find the path to the win, unless by pure accident it gets the mate within its horizon.

And yes, when the value head would not report the saturation value +1, but something around +0.5, there is room for it to encode progress, and the problem goes away. But then it would greatly err in the absolute value of KRK, giving +0.5 for a certain win. If it would not have been trained to similarly underestimate other wins you would have built in an inhibition to convert to KRK, which very well might be the only way to win more complex end-games.