SchaakMachine: Clear win

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

Moderators: hgm, Rebel, chrisw

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

SchaakMachine: Clear win

Post by Henk »

Finally a clear win against Fairy-Max

[pgn] [Event "Computer Chess Game"] [Site "HP"] [Date "2019.01.03"] [Round "-"] [White "SchaakMachine"] [Black "Fairy-Max 4.8S"] [Result "1/2-1/2"] [TimeControl "120"] [Annotator "1. +0.10 1... +0.22"] 1. f4 {+0.10/9} d5 {+0.22/8 2.6} 2. d4 {+0.04/9 2.1} c6 {+0.14/8 3} 3. Nc3 {+0.10/8 2.0} Be6 {+0.17/8 2.3} 4. Nf3 {+0.30/7 2.0} Nf6 {+0.02/8 3} 5. e3 {+0.26/8 2.0} g6 {-0.04/8 2.4} 6. Bd3 {+0.51/8 1.9} Bg7 {+0.03/8 2.5} 7. O-O {+0.48/8 1.9} O-O {+0.28/8 2.1} 8. Ne5 {+0.52/8 1.9} Nbd7 {+0.10/9 1.8} 9. Kh1 {+0.44/7 1.8} h5 {-0.01/8 1.6} 10. e4 {+0.62/7 1.8} Ng4 {+0.00/7 4} 11. Nf3 {+0.73/6 1.8} Ndf6 {-0.08/7 1.7} 12. e5 {+0.65/8 1.7} Ne8 {-0.21/8 1.2} 13. Ng5 {+0.74/8 1.7} Bd7 {-0.12/8 2.1} 14. f5 {+0.79/7 1.7} Bxf5 {-0.03/8 2.8} 15. Bxf5 {+0.54/8 1.6} gxf5 {-0.09/8 1.6} 16. h3 {+0.63/8 1.6} Nh6 {-0.48/10 3} 17. Qxh5 {+0.81/8 1.6} Qc8 {-0.56/9 2.4} 18. Nf3 {+1.06/7 1.6} Kh7 {-0.57/9 1.2} 19. g4 {+0.88/7 1.5} f6 {-2.37/9 4} 20. gxf5 {+3.08/8 1.5} Qxf5 {-2.44/10 1.0} 21. Ng5+ {+3.47/10 1.5} fxg5 {-2.48/11 1.0} 22. Rxf5 {+3.47/10 1.5} Rxf5 {-2.39/10 1.6} 23. Bxg5 {+3.41/8 1.4} Nf6 {-2.50/9 2.3} 24. Qh4 {+4.08/9 1.4} Ng8 {-2.60/9 1.3} 25. Bxe7 {+4.06/9 1.4} Nxe7 {-2.56/9 1.2} 26. Qxe7 {+4.08/9 1.4} Rf7 {-2.67/9 0.8} 27. Qg5 {+3.97/7 1.3} Re8 {-2.68/8 1.3} 28. Rg1 {+3.94/7 1.3} Re6 {-2.67/9 1.1} 29. Ne2 {+5.41/8 1.3} Re8 {-3.50/9 1.4} 30. Qg6+ {+6.29/9 1.3} Kh8 {-3.85/9 1.2} 31. e6 {+6.37/9 1.3} Rfe7 {-4.28/10 0.8} 32. Nf4 {+6.53/8 1.3} a5 {-4.34/10 1.2} 33. Qg5 {+7.20/7 1.2} Ng8 {-6.42/9 1.1} 34. Ng6+ {+8.81/8 1.2} Kh7 {-10.15/10 0.9} 35. Nxe7 {+9.99/8 1.2} Rxe7 {-8.91/12 1.0} 36. Rg4 {+10.97/8 1.2} Rc7 {-8.13/11 0.9} 37. c3 {+11.07/8 1.1} b5 {-7.50/9 0.7} 38. Qh4+ {+11.26/8 1.1} Nh6 {-8.81/11 1.6} 39. Rf4 {+11.30/8 1.1} Rc8 {-6.52/11 0.9} 40. e7 {+11.30/8 1.1} Re8 {-6.44/11 1.0} 41. a3 {+11.30/9 1.1} Kg6 {-6.58/10 1.0} 42. Qg3+ {+11.32/6 1.1} Kh7 {-7.23/10 1.0} 43. Qg5 {+11.30/8 1.0} Kg8 {-6.96/10 1.2} 44. Rf3 {+11.30/8 1.0} Nf7 {-6.78/12 2.0} 45. Qe3 {+10.48/7 1.0} Ne5 {-7.51/12 1.2} 46. dxe5 {+12.12/9 1.0} Rxe7 {-8.35/12 1.9} 47. e6 {+12.32/10 1.0} a4 {-9.24/11 1.4} 48. Qf4 {+13.79/8 1.0} b4 {-9.60/10 0.6} 49. cxb4 {+14.59/9 0.9} Rb7 {-12.33/11 1.5} 50. Qd6 {+15.45/8 0.9} Kh8 {-13.97/10 0.5} 51. Rf7 {+17.59/9 0.9} Rxf7 {-10.70/13 0.9} 52. exf7 {+18.96/9 0.9} Kh7 {-18.17/15 0.6} 53. Kg2 {+20.81/8 0.9} d4 {-9.93/12 0.5} 54. Kf3 {+20.83/8 0.9} d3 {-11.14/13 0.8} 55. Qxd3+ {+22.78/8 0.9} Kh6 {-11.94/13 0.5} 56. Qd6+ {+21.88/8 0.8} Kh7 {-12.81/13 0.7} 57. Qxc6 {+23.82/8 0.8} Bf8 {-18.13/13 0.5} 58. Qf6 {+26.60/8 0.8} Bg7 {-79.95/17 0.5} 59. Qg5 {+31.91/9 0.8} Bf8 {-79.95/18 0.6} 60. b5 {+31.88/8 0.8} Bd6 {-79.95/14 0.4} 61. b6 {+36.52/8 0.8} Bf8 {-79.95/16 0.5} 62. b7 {+39.06/8 0.8} Be7 {-79.96/18 0.5} 63. Qxe7 {+2621.35/8 0.7} Kh6 {-79.97/28 0.4} 64. Qf6+ {+2621.38/7 0.7} Kh5 {-79.98/28 0.1} 65. f8=Q {+2621.40/9 0.7} {Xboard adjudication: Stalemate} 1/2-1/2 [/pgn]
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: SchaakMachine: Clear win

Post by Henk »

Already found it:
I had to add extra condition: lb > -MIN_MATE_SCORE

Code: Select all

                // Add some noise to prohibit playing same games over again
                //              
                var noise = random.Next(0, 5 * CENTI_PAWN);
                if ( lb > -MIN_MATE_SCORE &&
                    (score - noise) > lb && (score + noise) < ub
                    && ub < MIN_MATE_SCORE - noise  // adding noise must not prohibit finding checkmates
                    )
                {
                    score += noise;
                }
 
Always the noise.

// adding noise must not prohibit finding stalemates too
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: SchaakMachine: Clear win

Post by hgm »

Indeed, adding noise in the root should not be done for mate scores.

I am not sure I understand your code. 'lb' and 'ub' are alpha and beta? The way I always do it is precompensate alpha and beta for the noise I am going to add. So

noise = Random();
score = Search(alpha - noise, beta - noise) + noise;

That way adding the noise will never make you cross the window limits.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: SchaakMachine: Clear win

Post by Henk »

Yes lb = lowerbound = alpha etcetera.

I remember trying that some time ago. Could not make it work.
Maybe I'll try again.

But anyhow SchaakMachine still playing (much) worse than FairyMax on 2 minutes games.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: SchaakMachine: Clear win

Post by Sven »

hgm wrote: Thu Jan 03, 2019 5:54 pm Indeed, adding noise in the root should not be done for mate scores.
@Henk: do you add "noise" only in the root, or everywhere?
I am not sure I understand your code. 'lb' and 'ub' are alpha and beta? The way I always do it is precompensate alpha and beta for the noise I am going to add. So

noise = Random();
score = Search(alpha - noise, beta - noise) + noise;

That way adding the noise will never make you cross the window limits.
Would it be a valid alternative to simply add "noise" to the static eval score, in order to keep the search code clean?
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: SchaakMachine: Clear win

Post by Henk »

Sven wrote: Thu Jan 03, 2019 10:44 pm
hgm wrote: Thu Jan 03, 2019 5:54 pm Indeed, adding noise in the root should not be done for mate scores.
@Henk: do you add "noise" only in the root, or everywhere?
I am not sure I understand your code. 'lb' and 'ub' are alpha and beta? The way I always do it is precompensate alpha and beta for the noise I am going to add. So

noise = Random();
score = Search(alpha - noise, beta - noise) + noise;

That way adding the noise will never make you cross the window limits.
Would it be a valid alternative to simply add "noise" to the static eval score, in order to keep the search code clean?
Everywhere but not in Qsearch.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: SchaakMachine: Clear win

Post by hgm »

Sven wrote: Thu Jan 03, 2019 10:44 pmWould it be a valid alternative to simply add "noise" to the static eval score, in order to keep the search code clean?
Sure, Joker does that. Downside is that you then have to do it a million times per second, instead of just a couple of hundred times per search. So you better use a fast PRNG in that case. For consistency it would be best to derive the noise from the hash key anyway (e.g. magicFactor*hashKey >> 59), where the magicFactor is taken different for every game. This might even improve the strength through the "Beal effect".

The main problem is that the randomness seems to diminish in this case as the search depth increases. But perhaps this can be avoided by changing the probability distribution for the noise. Just using a homogeneous distribution from -16 to +15 cP might not be ideal, as with enough depth every root move can probably steer to a leaf that happens to get +15 in the eval.
Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: SchaakMachine: Clear win

Post by Ras »

hgm wrote: Thu Jan 03, 2019 11:02 pmThe main problem is that the randomness seems to diminish in this case as the search depth increases.
Another option is replacing the eval by noise percentage. The actual noise is uniformly distributed between -50 and +50 centipawns, and the modified eval is like this where noise_percentage is ranged between 0 (no noise) and 100 (noise only):

new_eval = (noise * noise_percentage + (100 - noise_percentage) * real_eval) / 100

On top of that, certain search deepenings are not performed from certain noise levels onwards, and mate in either QS or main search is overlooked with a certain probability. Basically, noise_percentage is also the probability to overlook a mate in 1. That multiplies up for deeper mates so that e.g. a mate in 2 from the root is only found with a probability of (100% - noise_percentage)^2.
Rasmus Althoff
https://www.ct800.net
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: SchaakMachine: Clear win

Post by hgm »

Yes, this is a good way to weaken the engine (although not in a way that would make it resemble a human patzer).

But the question was not about weakening the engine, but about reducing determinism without significant loss of strength.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: SchaakMachine: Clear win

Post by Henk »

A narrow win due to "improved" passed pawn evaluation during endgame. 11 Na7??

[pgn] [Event "Computer Chess Game"] [Site "HP"] [Date "2019.01.04"] [Round "-"] [White "SchaakMachine"] [Black "Fairy-Max 4.8S"] [Result "1-0"] [TimeControl "120"] [Annotator "1. +0.10 1... +0.10"] 1. Nf3 {+0.10/7} d6 {+0.10/8 3} 2. d4 {+0.15/7 2.1} Bf5 {+0.20/7 2.1} 3. c4 {+0.24/7 2.0} Nf6 {+0.23/7 1.9} 4. Nc3 {+0.21/6 2.0} c6 {+0.02/8 4} 5. d5 {+0.26/5 2.0} cxd5 {-0.03/8 2.0} 6. Nd4 {+0.37/7 1.9} Bg6 {+0.10/9 1.4} 7. Qa4+ {+0.55/7 1.9} Qd7 {+0.10/8 1.7} 8. Qxd7+ {+0.27/7 1.9} Nbxd7 {+0.41/10 1.5} 9. Ndb5 {-0.18/8 1.9} Rc8 {+0.29/9 2.7} 10. cxd5 {-0.01/7 1.8} a6 {+0.36/10 2.1} 11. Na7 {-0.44/8 1.8} Ra8 {+0.39/9 1.3} 12. Be3 {-0.68/8 1.8} Nc5 {+0.55/10 1.3} 13. f3 {-0.69/8 1.7} Rxa7 {+0.62/10 1.6} 14. b4 {-0.66/7 1.7} b6 {+0.58/10 1.3} 15. bxc5 {-0.85/8 1.7} bxc5 {+0.61/11 1.9} 16. O-O-O {-0.90/7 1.6} e5 {+0.77/10 1.6} 17. g4 {-0.97/7 1.6} Be7 {+1.09/10 1.4} 18. h4 {-0.98/7 1.6} h5 {+1.03/11 1.1} 19. g5 {-0.74/7 1.5} Nd7 {+0.92/11 2.5} 20. Bf2 {-0.97/7 1.5} O-O {+0.98/10 1.3} 21. e4 {-1.05/6 1.5} f5 {+0.70/10 1.5} 22. Rd2 {-1.08/7 1.5} fxe4 {+0.78/10 1.2} 23. fxe4 {-1.47/8 1.4} Bd8 {+0.69/10 1.1} 24. Rh3 {-1.40/7 1.4} Bb6 {+0.75/9 1.1} 25. Bg2 {-1.45/7 1.4} c4 {+0.78/12 1.0} 26. Bxb6 {-1.46/8 1.4} Nxb6 {+0.67/11 1.1} 27. Rf3 {-1.59/6 1.3} Rxf3 {+0.70/11 1.2} 28. Bxf3 {-1.99/7 1.3} Nd7 {+0.78/12 2.8} 29. Be2 {-2.39/8 1.3} Nc5 {+0.96/11 1.0} 30. Bxc4 {-1.54/8 1.3} Rc7 {+0.94/13 1.4} 31. Kb2 {-1.41/9 1.3} Nxe4 {+1.02/13 4} 32. Nxe4 {-1.94/9 1.3} Rxc4 {+0.90/13 1.1} 33. Nxd6 {-0.75/8 1.2} Rc5 {+0.58/12 2.7} 34. Kb3 {-0.16/8 1.2} e4 {+0.40/12 1.2} 35. Nc4 {+0.75/8 1.2} Bf7 {+0.28/11 0.8} 36. Ne3 {+1.06/7 1.2} Rb5+ {+0.29/11 1.0} 37. Kc3 {+1.72/7 1.2} Rc5+ {-0.23/11 0.9} 38. Kb2 {+2.13/8 1.1} Rb5+ {+0.01/12 1.1} 39. Ka1 {+2.03/8 1.1} Rb7 {-0.36/12 1.2} 40. Rd4 {+2.16/7 1.1} Rb8 {-0.35/11 0.9} 41. d6 {+2.37/8 1.1} Rd8 {-0.39/12 1.2} 42. Nf5 {+2.41/7 1.0} Kh7 {-0.39/12 1.4} 43. a3 {+2.07/7 1.1} g6 {-0.19/13 0.8} 44. Ne3 {+2.11/9 1.0} Be6 {-0.22/14 1.8} 45. a4 {+1.99/10 1.0} a5 {-0.26/13 1.0} 46. Kb2 {+1.75/8 1.0} Rb8+ {-0.17/11 1.0} 47. Kc2 {+1.54/8 1.0} Rb4 {-0.53/11 0.7} 48. Rxb4 {+6.82/11 1.0} axb4 {-6.41/15 0.6} 49. a5 {+10.81/10 1.0} b3+ {-6.57/14 2.2} 50. Kb2 {+11.76/10 0.9} Kg7 {-7.19/14 0.8} 51. a6 {+11.77/10 0.9} Bd7 {-8.70/14 0.9} 52. a7 {+13.95/8 0.9} Bc6 {-10.06/13 0.5} 53. Kxb3 {+13.95/9 0.9} Kf7 {-2.71/13 1.0} 54. Kb4 {+13.85/9 0.9} Ke6 {-2.95/13 0.5} 55. Kc5 {+13.85/9 0.9} Kd7 {-3.00/14 0.5} 56. Nc4 {+14.85/9 0.8} Bb7 {-4.40/14 1.2} 57. Ne5+ {+15.05/9 0.8} Kd8 {-7.28/14 1.4} 58. Nxg6 {+15.40/8 0.8} e3 {-9.87/14 1.6} 59. Nf4 {+17.72/8 0.8} Ba8 {-9.88/12 0.8} 60. g6 {+23.06/8 0.8} Ke8 {-10.78/12 0.5} 61. Kd4 {+25.44/8 0.8} e2 {-10.80/12 0.5} 62. Nxe2 {+25.43/8 0.8} Bf3 {-11.42/12 0.9} 63. Ng3 {+26.37/7 0.7} Kf8 {-12.50/12 1.2} 64. d7 {+28.65/7 0.8} Ke7 {-16.42/12 0.8} 65. g7 {+25.81/7 0.7} Bb7 {-13.10/11 0.5} 66. d8=Q+ {+28.64/7 0.7} Kxd8 {-16.86/12 0.5} 67. g8=Q+ {+26.47/7 0.7} Kd7 {-20.34/11 1.2} 68. Qf7+ {+25.27/6 0.7} Kc6 {-20.30/11 0.8} 69. Qb3 {+25.27/6 0.7} Kc7 {-20.24/10 0.3} 70. Nxh5 {+25.27/6 0.7} Bg2 {-14.07/9 0.5} 71. Nf6 {+28.54/6 0.7} Kd6 {-79.96/10 0.4} 72. h5 {+31.83/6 0.7} Ke7 {-17.85/9 0.4} 73. h6 {+32.34/6 0.6} Kxf6 {-22.62/10 0.9} 74. h7 {+35.43/6 0.6} Ke7 {-79.96/9 0.4} 75. Ke5 {+36.57/6 0.6} Bh3 {-79.97/13 0.4} 76. h8=Q {+2621.37/6 0.6} Bg4 {-79.98/28 0.2} 77. Qhg8 {+2621.39/6 0.6} Be6 {-79.99/28 0.1} 78. Qbxe6# {+2621.41/7 0.6} {Xboard adjudication: Checkmate} 1-0 [/pgn]