Smooth scaling stockfish

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Smooth scaling stockfish

Post by Dann Corbit »

Daniel Shawul wrote:That is awesome Dann. I am going to try it with Scorpio and see if I can get anything.
I guess that you will want to try to fit the curve so that it approximately goes through the existing points in your reduction curve (or stair-steps as current reductions tend to be).

I suspect that various curve families will have different benefits and it will be a fun place for exploration.
Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Smooth scaling stockfish

Post by Dann Corbit »

Karlo Bala wrote:
Dann Corbit wrote:This version of Stockfish:
http://cap.connx.com/chess-engines/new- ... x64_ja.rar

Scales null move smoothly. I get about +150 Elo so far in my testing. How about yours?
Something similar was done in rob*****:

Code: Select all

        null_do();
        hole_new = DEPTH - null_riduzione; 
        hole_new -= ((uint32)(MINIMUM(POSITION_0->value - VALUE, 96))) / 32;
He seems to have gotten away with a lot less math. Maybe it is a better idea.

However, this approach does not account for existing depth and the reductions will be titanic for huge scores (which is perhaps a good thing).
adieguez

Re: Smooth scaling stockfish

Post by adieguez »

Gian-Carlo Pascutto wrote:
Dann Corbit wrote: I doubt that 150 Elo will hold, but I guess at least 100 Elo will. Then again, my test was not very extensive.
For me it seems 15 ELO worse than regular nullmove.
but please say in which conditions. Dann says he used only 30 games, which is of course little.

I often get results like this with few games: (off course with more games it gets back to reality)

Program Elo + - Games Score Av.Op. Draws

1 Delfi 5.4 : 2566 48 47 168 64.3 % 2464 23.8 %
2 Amyan exp59 : 2544 104 101 40 65.0 % 2436 20.0 %
3 Crafty-23.0 : 2539 50 50 164 59.8 % 2470 15.9 %
4 Fruit 2.1 : 2528 50 49 156 58.3 % 2470 20.5 %
5 WildCat 8 : 2520 50 50 160 57.2 % 2469 16.9 %
6 Booot 4.15.0 : 2516 48 48 166 56.6 % 2470 19.3 %
7 Doch32 09.980 JA : 2499 48 48 166 54.8 % 2465 18.1 %
...
produced with elostat 1.3 by Dr. Frank Schubert

About nullmove... I haven't been able to improve it very much, but still Dann gaveme an idea because am using the hash and the eval at the same time. But as he did I can try not using always the eval depending on the hash result.
User avatar
Eelco de Groot
Posts: 4565
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: Smooth scaling stockfish

Post by Eelco de Groot »

Dann Corbit wrote:
Karlo Bala wrote:
Dann Corbit wrote:This version of Stockfish:
http://cap.connx.com/chess-engines/new- ... x64_ja.rar

Scales null move smoothly. I get about +150 Elo so far in my testing. How about yours?
Something similar was done in rob*****:

Code: Select all

        null_do();
        hole_new = DEPTH - null_riduzione; 
        hole_new -= ((uint32)(MINIMUM(POSITION_0->value - VALUE, 96))) / 32;
He seems to have gotten away with a lot less math. Maybe it is a better idea.

However, this approach does not account for existing depth and the reductions will be titanic for huge scores (which is perhaps a good thing).
I was thinking about something more simple too, avoiding floating point calculations if I can. Basically using the value from hash is like doing the verification search for free before, or maybe even instead of, null-move search. You maybe can get away with not searching at all but it is a bit dangerous :) More conservative approach is severely downsizing null-move depth if the quality of your pre-verification search is good enough and the value found is high enough above beta. Then you do not really need any deep null move search, also possibly because

a) long null move searches are only searching nonsense,

b) do not improve the quality of threat moves -important in Stockfish- much and

c) pollute the hashtable.

For instance, you can decide not to null move at all if you find no hash information, forcing you to search so at least the next time you pass here you have a good pre-verification search done. I'm not sure if it helps but that is what I am doing in Rainbow Serpent at the moment. In Ancalagon I did different things. The Null move dynamic reduction is all just copied from Stockfish but there you could do more, just as Robbolito/Ippolit/Rybka seems to be doing and just as in the Smooth Scaling Null Move from you Dann.

These are the present conditions for doing null move in Rainbow Serpent but they are not very sophisticated:

Code: Select all


    // Null move search
    if (    allowNullmove
        &&  depth > OnePly
        && !isCheck
        && !value_is_mate(beta)
        && &#40;ttValue >= beta || ttDepth <= depth-2*OnePly&#41;        
        &&  approximateEval >= beta - NullMoveMargin
        &&  ok_to_do_nullmove&#40;pos&#41;)
    &#123;
        ss&#91;ply&#93;.currentMove = MOVE_NULL;

        StateInfo st;
        pos.do_null_move&#40;st&#41;;
        int R = &#40;depth >= 5 * OnePly ? 4 &#58; 3&#41;; // Null move dynamic reduction, no changes from Stockfish here

        if &#40;ss&#91;ply - 2&#93;.currentMove == MOVE_NULL&#41; nullBeta = beta + 0x20;
		
        Value nullValue = -search&#40;pos, ss, -&#40;nullBeta-1&#41;, depth-R*OnePly, ply+1, false, threadID&#41;;

As it is, I always have both ttValue and ttDepth when starting a null move search and I think you can do much more with it, just like in Smooth Scaling Nullmove.
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
Michael Sherwin
Posts: 3196
Joined: Fri May 26, 2006 3:00 am
Location: WY, USA
Full name: Michael Sherwin

Re: Smooth scaling stockfish

Post by Michael Sherwin »

Michael Sherwin wrote:
BubbaTough wrote:
Dann Corbit wrote:
BubbaTough wrote:
Dann Corbit wrote:This version of Stockfish:
http://cap.connx.com/chess-engines/new- ... x64_ja.rar

Scales null move smoothly. I get about +150 Elo so far in my testing. How about yours?
I am not sure what you mean by smooth scaling, and don't see any attached source code.


-Sam
Here are the changes from version 1.61:
http://cap.connx.com/chess-engines/new-approach/sfc.zip

Note that I do not have the 1.62 sources, which have additional corrections.

I guess that the curve can be greatly improved. It was a first hack eyeball guestimate.
Ahh, gotcha. I did something similar in LearningLemming, and I think I got the idea from something Michael Sherwin was trying in Romi (though I think he scaled it differently) so I imagine Romi also does it. Its nice to see it work for someone else too. It always amazes me that some ideas can work so well for some authors, and not for others.

-Sam
I was working on something to do with modifying the null move search. And I remember that Romi got very good results. But, I got distracted and forgot about it. Given my memory problems, I can not say if this is similar to what I was doing or not. I will go digging through my old post to see if I can find it. Romi could use another 150 elo right about now! However, I will wait until later to make a claim that yet another one of my ideas has made it into Glaurung/Stockfish. :D
In RomiChess:
score = -Search(-beta, -beta + 1, depth - 3 - (depth > 5), 0);

I guess that the "depth - 3 - (depth > 5)" is the scaling of the Null_Move_Reduction that is the basic idea. I experimented with depth - 3 (r=2) and depth - 4 (r=3) and couldn't figure out which was better. depth - 4 seemed too aggressive towards the leaves, so I decided to only use that value further away. depth > 5 tested best. Dann's "smoothie" is far more sophisticated than my basic idea!

Two notes:

1) Olithink uses/used this exact same - (depth > 5) and was before RomiChess, however, I came up with this on my own.

2) What I was referring to above in my first post was not this but something else.
If you are on a sidewalk and the covid goes beep beep
Just step aside or you might have a bit of heat
Covid covid runs through the town all day
Can the people ever change their ways
Sherwin the covid's after you
Sherwin if it catches you you're through
Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Smooth scaling stockfish

Post by Dann Corbit »

Michael Sherwin wrote:
Michael Sherwin wrote:
BubbaTough wrote:
Dann Corbit wrote:
BubbaTough wrote:
Dann Corbit wrote:This version of Stockfish:
http://cap.connx.com/chess-engines/new- ... x64_ja.rar

Scales null move smoothly. I get about +150 Elo so far in my testing. How about yours?
I am not sure what you mean by smooth scaling, and don't see any attached source code.


-Sam
Here are the changes from version 1.61:
http://cap.connx.com/chess-engines/new-approach/sfc.zip

Note that I do not have the 1.62 sources, which have additional corrections.

I guess that the curve can be greatly improved. It was a first hack eyeball guestimate.
Ahh, gotcha. I did something similar in LearningLemming, and I think I got the idea from something Michael Sherwin was trying in Romi (though I think he scaled it differently) so I imagine Romi also does it. Its nice to see it work for someone else too. It always amazes me that some ideas can work so well for some authors, and not for others.

-Sam
I was working on something to do with modifying the null move search. And I remember that Romi got very good results. But, I got distracted and forgot about it. Given my memory problems, I can not say if this is similar to what I was doing or not. I will go digging through my old post to see if I can find it. Romi could use another 150 elo right about now! However, I will wait until later to make a claim that yet another one of my ideas has made it into Glaurung/Stockfish. :D
In RomiChess:
score = -Search(-beta, -beta + 1, depth - 3 - (depth > 5), 0);

I guess that the "depth - 3 - (depth > 5)" is the scaling of the Null_Move_Reduction that is the basic idea. I experimented with depth - 3 (r=2) and depth - 4 (r=3) and couldn't figure out which was better. depth - 4 seemed too aggressive towards the leaves, so I decided to only use that value further away. depth > 5 tested best. Dann's "smoothie" is far more sophisticated than my basic idea!

Two notes:

1) Olithink uses/used this exact same - (depth > 5) and was before RomiChess, however, I came up with this on my own.

2) What I was referring to above in my first post was not this but something else.
The idea above is very similar to the method described in "Scalable Search in Computer Chess" by Ernst A. Heinz which was written in 1999
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Smooth scaling stockfish

Post by bob »

Zach Wegner wrote:
mcostalba wrote:
Dann Corbit wrote:
BubbaTough wrote:
Dann Corbit wrote:This version of Stockfish:
http://cap.connx.com/chess-engines/new- ... x64_ja.rar

Scales null move smoothly. I get about +150 Elo so far in my testing. How about yours?
I am not sure what you mean by smooth scaling, and don't see any attached source code.


-Sam
Here are the changes from version 1.61:
http://cap.connx.com/chess-engines/new-approach/sfc.zip

Note that I do not have the 1.62 sources, which have additional corrections.

I guess that the curve can be greatly improved. It was a first hack eyeball guestimate.

Ahaaaaa you changed the indentation of the functions !!! ;-)

In a project where more then one people work changing indentation of the whole file is never a good idea. It becomes difficult to spot the real differences for no gain at all.

Anyhow thanks !!! I will test for sure :-)
diff --ignore-space-change

:D
also use "indent" to make all indentations consistent.
BubbaTough
Posts: 1154
Joined: Fri Jun 23, 2006 5:18 am

Re: Smooth scaling stockfish

Post by BubbaTough »

Dann Corbit wrote:
Michael Sherwin wrote:
Michael Sherwin wrote:
BubbaTough wrote:
Dann Corbit wrote:
BubbaTough wrote:
Dann Corbit wrote:This version of Stockfish:
http://cap.connx.com/chess-engines/new- ... x64_ja.rar

Scales null move smoothly. I get about +150 Elo so far in my testing. How about yours?
I am not sure what you mean by smooth scaling, and don't see any attached source code.


-Sam
Here are the changes from version 1.61:
http://cap.connx.com/chess-engines/new-approach/sfc.zip

Note that I do not have the 1.62 sources, which have additional corrections.

I guess that the curve can be greatly improved. It was a first hack eyeball guestimate.
Ahh, gotcha. I did something similar in LearningLemming, and I think I got the idea from something Michael Sherwin was trying in Romi (though I think he scaled it differently) so I imagine Romi also does it. Its nice to see it work for someone else too. It always amazes me that some ideas can work so well for some authors, and not for others.

-Sam
I was working on something to do with modifying the null move search. And I remember that Romi got very good results. But, I got distracted and forgot about it. Given my memory problems, I can not say if this is similar to what I was doing or not. I will go digging through my old post to see if I can find it. Romi could use another 150 elo right about now! However, I will wait until later to make a claim that yet another one of my ideas has made it into Glaurung/Stockfish. :D
In RomiChess:
score = -Search(-beta, -beta + 1, depth - 3 - (depth > 5), 0);

I guess that the "depth - 3 - (depth > 5)" is the scaling of the Null_Move_Reduction that is the basic idea. I experimented with depth - 3 (r=2) and depth - 4 (r=3) and couldn't figure out which was better. depth - 4 seemed too aggressive towards the leaves, so I decided to only use that value further away. depth > 5 tested best. Dann's "smoothie" is far more sophisticated than my basic idea!

Two notes:

1) Olithink uses/used this exact same - (depth > 5) and was before RomiChess, however, I came up with this on my own.

2) What I was referring to above in my first post was not this but something else.
The idea above is very similar to the method described in "Scalable Search in Computer Chess" by Ernst A. Heinz which was written in 1999
Gotcha. So I guess something Sherwin said inspired me to come up with something similar to what is in "Scalable Search in Computer Chess" by Ernst A. Heinz, which is what inspired Corbit to come up with something similar for Stockfish. Ahh, if only everything were so simple.

-Sam
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Smooth scaling stockfish

Post by bob »

BubbaTough wrote:
bob wrote:
Dann Corbit wrote:
bob wrote:
Dann Corbit wrote:This version of Stockfish:
http://cap.connx.com/chess-engines/new- ... x64_ja.rar

Scales null move smoothly. I get about +150 Elo so far in my testing. How about yours?
I never got that idea to work, but I did test it quite a few years ago when depths were not as significant. In fact, Ernst and I developed the "adaptive null-move idea" independently. John Stanback had suggested the basics for the idea around 1995 or so. Initially it was a question of R=1 or R=2, but eventually became R=2 or R=3. I used to have fractional plies, and tried a gradual and continuous (smooth) reduction as it approached the frontier nodes, but never found something that worked any better than the simple R=3 closer to the root, R=2 closer to the leaves.
With Stockfish 1.6, I get a branching factor of well under 2. It clearly adds strength. I guess that when the idea is polished, it will be a lot better. I have other experiments that do something similar (well, actually the opposite as far as pruning goes -- so I guessed it would help) but I thought a quick demonstration of the idea might benefit the chess community.
I haven't looked but what is the "range"? I used to use 3 down to 2, but when I added the qsearch check and check-evasion code, I went with 3 everywhere. If they reduce more than 3, I could see a possible benefit...
It sounds like to me you really haven't tried this idea before. It is not at all like the "adaptive null-move" idea from 1995 in my mind. Perhaps you should look at the code, it is not complicated. It looks like a variation of the adaptive depth Sherwin talked about a couple years ago (I can't really remember exactly what he did, maybe something similar to nullDepth = 2+depth/3 or something). The version Corbit proposes here is more similar to what I eventually settled on. Its a little sad to see the concept get so much more press when added to a strong engine, than when the depth dependent idea was introduced into a weaker engine like Romi, but perhaps the stronger emphasis in Corbit's version on delta contributes enough to distinguish itself from Sherwin's concepts.

-Sam
We didn't try that exact curve, but I spent about 3 months prior to releasing 23.0 playing with hundreds of things with null-move + forward pruning I am using. I did try lots of ideas suggested here, such as using 4 near the root to 2 near the tips, I tried a smooth / gradual change in fractions of a ply. Nothing helped. And in fact, I produced the best results with pure R=3 (after adding qsearch checks) and even removed the jump from 3 to 2, now using R=3 everywhere in the tree...

I could probably enumerate most of the ideas we tried, but probably 50% were no change, and the rest were worse (excepting the flat change to R=3 everywhere. R=4 drops the strength a bit. R=3-4 drops the strength a little bit. Etc... We tried limiting based on a call to the full Eval, to a fast Eval, a hash probe (when successful) and so forth.

+150 makes absolutely no sense however, to an idea that is worth maybe +80 overall. +20 _might_ be possible, but not +150. If it were that easy, someone would already be using this.
Uri Blass
Posts: 10282
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Smooth scaling stockfish

Post by Uri Blass »

Dann Corbit wrote:
Tord Romstad wrote:
Dann Corbit wrote:This version of Stockfish:
http://cap.connx.com/chess-engines/new- ... x64_ja.rar

Scales null move smoothly. I get about +150 Elo so far in my testing. How about yours?
I hope I'm wrong, but this is extremely hard to believe. I would be pleasantly surprised if this change increased the strength even by 20 Elo points. I haven't done any tests yet, though.

How did you test this?
Someone else got +100:
http://www.talkchess.com/forum/viewtopi ... 90&t=31331

Unfortunately, my initial post had a link to a version that did not correctly incorporate my changes due to a titanic iceberg collision in my tiny little brain.

I suggest that you compile my simple changes and test it yourself. I guess that you will see the same thing that I do. It appears that Stockfish is easily as strong as Rybka now (but -- of course -- further testing may make this statement look very silly).
I can say that it is not serious to test a program only against previous version
and decide based on it if it is an improvement.

We have some estimate for the difference from rybka3 based on CEGT so
I could expect at least some games against rybka3 before giving an estimate for the improvement.

I think that
30 games is also too small to claim 150 elo improvement unless you write also the number of games that you used(nothing wrong in claiming that a program got performance that is 150 elo better after 30 games but it was not written in this way and caused a wrong impression).

Uri