Skip to content

Conversation

@locutus2
Copy link
Member

@locutus2 locutus2 commented Nov 5, 2021

Maintain for each root move an exponential average of the search value with a weight ratio of 2:1 (new value vs old values). Then the average score is used as the center of the initial aspiration window instead of the previous score.

For this test i had collected some interresting statistics on my 1000 positions bench:

  1. using previous score: mean difference of previous score and found search value
    [all depths] Total 37359 Mean 51.4138
    [depth=1] Total 74 Mean 294.986
    [depth=2] Total 3253 Mean -130.099
    [depth=3] Total 2246 Mean 162.687
    [depth=4] Total 3775 Mean 144.603
    [depth=5] Total 3416 Mean 108.089
    [depth=6] Total 3407 Mean 71.6228
    [depth=7] Total 3487 Mean 71.8959
    [depth=8] Total 3573 Mean 44.8483
    [depth=9] Total 3315 Mean 33.4992
    [depth=10] Total 3198 Mean 29.0075
    [depth=11] Total 3039 Mean 22.7943
    [depth=12] Total 2608 Mean 23.9628
    [depth=13] Total 1968 Mean 25.9639

  2. using average score: mean difference of last average score (not including current search value) and found search value
    [all depths] Total 673613 Mean 10.3302
    [depth=1] Total 1441 Mean 105.351
    [depth=2] Total 31878 Mean 11.5225
    [depth=3] Total 41230 Mean 107.319
    [depth=4] Total 60369 Mean 38.8653
    [depth=5] Total 68015 Mean 20.5957
    [depth=6] Total 66504 Mean 10.4651
    [depth=7] Total 68946 Mean 4.85171
    [depth=8] Total 69448 Mean 9.51513
    [depth=9] Total 60509 Mean -8.85936
    [depth=10] Total 61270 Mean -11.213
    [depth=11] Total 59268 Mean -12.3605
    [depth=12] Total 47883 Mean -17.7107
    [depth=13] Total 36852 Mean -16.8232

This stats indicate that the deviation for previous score is in general greater than using average score, so later seems a better estimation of the next search value. This is probably the reason this patch succeded besides smoothing the sometimes wild swings in search score. An additional observation is that at higher depth previous score is above but average score below zero. So for average score more/less fail/low highs should be occur than previous score.

The same picture shows a measurement of linear correlations (for higher depth they start to converge):

  1. using previous score: linear correlation of previous score and found search value
    [all depths] Total 37359 Correlation(x,y) = 0.634061
    [depth=1] Total 74 Correlation(x,y) = 0.712144
    [depth=2] Total 3253 Correlation(x,y) = 0.458019
    [depth=3] Total 2246 Correlation(x,y) = 0.493131
    [depth=4] Total 3775 Correlation(x,y) = 0.641849
    [depth=5] Total 3416 Correlation(x,y) = 0.946575
    [depth=6] Total 3407 Correlation(x,y) = 0.9026
    [depth=7] Total 3487 Correlation(x,y) = 0.69803
    [depth=8] Total 3573 Correlation(x,y) = 0.947752
    [depth=9] Total 3315 Correlation(x,y) = 0.966204
    [depth=10] Total 3198 Correlation(x,y) = 0.908967
    [depth=11] Total 3039 Correlation(x,y) = 0.942879
    [depth=12] Total 2608 Correlation(x,y) = 0.880256
    [depth=13] Total 1968 Correlation(x,y) = 0.945462

  2. using average score: linear correlation of last average score (not including current search value) and found search value
    [all depths] Total 673613 Correlation(x,y) = 0.949564
    [depth=1] Total 1441 Correlation(x,y) = 0.98196
    [depth=2] Total 31878 Correlation(x,y) = 0.807721
    [depth=3] Total 41230 Correlation(x,y) = 0.815621
    [depth=4] Total 60369 Correlation(x,y) = 0.952998
    [depth=5] Total 68015 Correlation(x,y) = 0.952568
    [depth=6] Total 66504 Correlation(x,y) = 0.966561
    [depth=7] Total 68946 Correlation(x,y) = 0.976207
    [depth=8] Total 69448 Correlation(x,y) = 0.959745
    [depth=9] Total 60509 Correlation(x,y) = 0.956626
    [depth=10] Total 61270 Correlation(x,y) = 0.95662
    [depth=11] Total 59268 Correlation(x,y) = 0.967777
    [depth=12] Total 47883 Correlation(x,y) = 0.970461
    [depth=13] Total 36852 Correlation(x,y) = 0.962927

STC:
LLR: 2.97 (-2.94,2.94) <0.00,2.50>
Total: 59792 W: 15106 L: 14792 D: 29894
Ptnml(0-2): 144, 6718, 15869, 7010, 155
https://tests.stockfishchess.org/tests/view/61841612d7a085ad008eef06

LTC:
LLR: 2.94 (-2.94,2.94) <0.50,3.00>
Total: 46448 W: 11835 L: 11537 D: 23076
Ptnml(0-2): 21, 4756, 13374, 5050, 23
https://tests.stockfishchess.org/tests/view/618463abd7a085ad008eef3e

Bench: 7047335

Maintain for each root move an exponential average of the search value with a weight ratio of 2:1 (new value vs old values). Then the average score is used as the center of the initial aspiration window instead of the previous score.

For this test i had collected some interresting statistics on my 1000 positions bench:
1. using previous score: mean difference of previous score and found search value
[all depths] Total 37359 Mean 51.4138
[depth=1] Total 74 Mean 294.986
[depth=2] Total 3253 Mean -130.099
[depth=3] Total 2246 Mean 162.687
[depth=4] Total 3775 Mean 144.603
[depth=5] Total 3416 Mean 108.089
[depth=6] Total 3407 Mean 71.6228
[depth=7] Total 3487 Mean 71.8959
[depth=8] Total 3573 Mean 44.8483
[depth=9] Total 3315 Mean 33.4992
[depth=10] Total 3198 Mean 29.0075
[depth=11] Total 3039 Mean 22.7943
[depth=12] Total 2608 Mean 23.9628
[depth=13] Total 1968 Mean 25.9639

2. using average score: mean difference of last average score (not including current search value) and found search value
[all depths] Total 673613 Mean 10.3302
[depth=1] Total 1441 Mean 105.351
[depth=2] Total 31878 Mean 11.5225
[depth=3] Total 41230 Mean 107.319
[depth=4] Total 60369 Mean 38.8653
[depth=5] Total 68015 Mean 20.5957
[depth=6] Total 66504 Mean 10.4651
[depth=7] Total 68946 Mean 4.85171
[depth=8] Total 69448 Mean 9.51513
[depth=9] Total 60509 Mean -8.85936
[depth=10] Total 61270 Mean -11.213
[depth=11] Total 59268 Mean -12.3605
[depth=12] Total 47883 Mean -17.7107
[depth=13] Total 36852 Mean -16.8232

This stats indicate that the deviation for previous score is in general greater than using average score, so later seems a better estimation of the next search value. This is probably the reason this patch succeded besides smoothing the sometimes wild swings in search score. An additional observation is that at higher depth previous score is above but average score below zero. So for average score more/less fail/low highs should be occur than previous score.

The same picture shows a measurement of linear correlations (for higher depth they start to converge):
1. using previous score: linear correlation of previous score and found search value
[all depths] Total 37359 Correlation(x,y) = 0.634061
[depth=1] Total 74 Correlation(x,y) = 0.712144
[depth=2] Total 3253 Correlation(x,y) = 0.458019
[depth=3] Total 2246 Correlation(x,y) = 0.493131
[depth=4] Total 3775 Correlation(x,y) = 0.641849
[depth=5] Total 3416 Correlation(x,y) = 0.946575
[depth=6] Total 3407 Correlation(x,y) = 0.9026
[depth=7] Total 3487 Correlation(x,y) = 0.69803
[depth=8] Total 3573 Correlation(x,y) = 0.947752
[depth=9] Total 3315 Correlation(x,y) = 0.966204
[depth=10] Total 3198 Correlation(x,y) = 0.908967
[depth=11] Total 3039 Correlation(x,y) = 0.942879
[depth=12] Total 2608 Correlation(x,y) = 0.880256
[depth=13] Total 1968 Correlation(x,y) = 0.945462

2. using average score: linear correlation of last average score (not including current search value) and found search value
[all depths] Total 673613 Correlation(x,y) = 0.949564
[depth=1] Total 1441 Correlation(x,y) = 0.98196
[depth=2] Total 31878 Correlation(x,y) = 0.807721
[depth=3] Total 41230 Correlation(x,y) = 0.815621
[depth=4] Total 60369 Correlation(x,y) = 0.952998
[depth=5] Total 68015 Correlation(x,y) = 0.952568
[depth=6] Total 66504 Correlation(x,y) = 0.966561
[depth=7] Total 68946 Correlation(x,y) = 0.976207
[depth=8] Total 69448 Correlation(x,y) = 0.959745
[depth=9] Total 60509 Correlation(x,y) = 0.956626
[depth=10] Total 61270 Correlation(x,y) = 0.95662
[depth=11] Total 59268 Correlation(x,y) = 0.967777
[depth=12] Total 47883 Correlation(x,y) = 0.970461
[depth=13] Total 36852 Correlation(x,y) = 0.962927

STC:
LLR: 2.97 (-2.94,2.94) <0.00,2.50>
Total: 59792 W: 15106 L: 14792 D: 29894
Ptnml(0-2): 144, 6718, 15869, 7010, 155
https://tests.stockfishchess.org/tests/view/61841612d7a085ad008eef06

LTC:
LLR: 2.94 (-2.94,2.94) <0.50,3.00>
Total: 46448 W: 11835 L: 11537 D: 23076
Ptnml(0-2): 21, 4756, 13374, 5050, 23
https://tests.stockfishchess.org/tests/view/618463abd7a085ad008eef3e

Bench: 7047335
@locutus2
Copy link
Member Author

locutus2 commented Nov 5, 2021

Updated PR text with a forced push.

@vondele vondele closed this in a0259d8 Nov 5, 2021
@snicolet
Copy link
Member

snicolet commented Nov 5, 2021

What will be the behaviour of this patch in the presence of table bases?

@locutus2
Copy link
Member Author

locutus2 commented Nov 5, 2021

@snicolet
That is an interresting question:

  1. the same applies for mate or other known win scores. So perhaps it would be could to check on our mate suite to see if it their hurts.
  2. this is a weighted average with a heavy favor the last value, so old values fade out fast. But nevertheless the would some delay. The question is if in this case this is outweighted by smoothing effect.
  3. Say if we have a wild swing of values (say TB/mate win found/not found in alternative searches) i don't know what is better. An averaged value of the swinging scores. I personnaly think probably the former because its helps search stability.

But perhaps a match with TB at endgame positions could give more clarity. But as i said the same effect should apply to mates.

@vondele
Copy link
Member

vondele commented Nov 5, 2021

I'll run a mate check.

@vondele
Copy link
Member

vondele commented Nov 5, 2021

Essentially identical number of mates found with and without this patch:

    master  2263
     patch  2255

@locutus2
Copy link
Member Author

locutus2 commented Nov 5, 2021

@vondele
Thanks. I have finished now my own matecheck at 1M nodes and i get the same numbers.

master:
Total fens: 6566
Found mates: 3231
Best mates: 2255

master with old window:
Total fens: 6566
Found mates: 3283
Best mates: 2263

@snicolet
Copy link
Member

snicolet commented Nov 6, 2021

Maybe we could initialize the value like that:

Value prev = rootMoves[pvIdx].previousScore;
if (abs(prev) < VALUE_KNOWN_WIN)
   prev = rootMoves[pvIdx].averageScore;

@locutus2
Copy link
Member Author

locutus2 commented Nov 6, 2021

@snicolet
Yeah, you can try it. But what i think your condition could probably help more at my original tried idea. Their i used the average as replacement for the found search value at root. I think here it could be more important to use an exact score for winning scores.

@snicolet snicolet added the to be merged Will be merged shortly label Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

to be merged Will be merged shortly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants