Smooth scaling stockfish

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: table

Post by Daniel Shawul »

Hopefully more readable

Code: Select all

3	 50	3.00
3	100	3.00
3	150	3.00
3	200	3.00
3	250	3.00
3	300	3.00
3	350	3.00
3	400	3.00
3	450	3.00
3	500	3.00
3	550	3.00
4	 50	4.00
4	100	4.00
4	150	4.00
4	200	4.00
4	250	4.00
4	300	4.00
4	350	4.00
4	400	4.00
4	450	4.00
4	500	4.00
4	550	4.00
5	 50	4.34
5	100	4.40
5	150	4.44
5	200	4.46
5	250	4.48
5	300	4.50
5	350	4.51
5	400	4.52
5	450	4.53
5	500	4.54
5	550	4.55
6	 50	4.52
6	100	4.58
6	150	4.62
6	200	4.64
6	250	4.66
6	300	4.68
6	350	4.69
6	400	4.70
6	450	4.71
6	500	4.72
6	550	4.73
7	 50	4.70
7	100	4.76
7	150	4.80
7	200	4.82
7	250	4.84
7	300	4.86
7	350	4.87
7	400	4.88
7	450	4.89
7	500	4.90
7	550	4.91
8	 50	4.88
8	100	4.94
8	150	4.98
8	200	5.00
8	250	5.02
8	300	5.04
8	350	5.05
8	400	5.06
8	450	5.07
8	500	5.08
8	550	5.09
9	 50	5.06
9	100	5.12
9	150	5.16
9	200	5.18
9	250	5.20
9	300	5.22
9	350	5.23
9	400	5.24
9	450	5.25
9	500	5.26
9	550	5.27
10	 50	5.24
10	100	5.30
10	150	5.34
10	200	5.36
10	250	5.38
10	300	5.40
10	350	5.41
10	400	5.42
10	450	5.43
10	500	5.44
10	550	5.45
11	 50	5.42
11	100	5.48
11	150	5.52
11	200	5.54
11	250	5.56
11	300	5.58
11	350	5.59
11	400	5.60
11	450	5.61
11	500	5.62
11	550	5.63
12	 50	5.60
12	100	5.66
12	150	5.70
12	200	5.72
12	250	5.74
12	300	5.76
12	350	5.77
12	400	5.78
12	450	5.79
12	500	5.80
12	550	5.81
13	 50	5.78
13	100	5.84
13	150	5.88
13	200	5.90
13	250	5.92
13	300	5.94
13	350	5.95
13	400	5.96
13	450	5.97
13	500	5.98
13	550	5.99
14	 50	5.96
14	100	6.02
14	150	6.06
14	200	6.08
14	250	6.10
14	300	6.12
14	350	6.13
14	400	6.14
14	450	6.15
14	500	6.16
14	550	6.17

mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: table

Post by mcostalba »

This is with current 1.6 reduction comparison:

Code: Select all


D = Depth
M = margin

D    M    Dann   SF 1.6
--------------------------------
3	100	3       3
3	200	3       3
3	300	3       4
3	400	3       4
3	500	3       4

4	100	4       3
4	200	4       3
4	300	4       4
4	400	4       4
4	500	4       4

5	100	4       3
5	200	4       3
5	300	4       4
5	400	4       4
5	500	4       4

6	100	4       4
6	200	4       4
6	300	4       5
6	400	4       5
6	500	4       5

7	100	4      4
7	200	4      4
7	300	4      5
7	400	4      5
7	500	4      5

8	100	4      4
8	200	5      4
8	300	5      5
8	400	5      5
8	500	5      5

9	100	5      4
9	200	5      4
9	300	5      5
9	400	5      5
9	500	5      5

10	100	5      4
10	200	5      4
10	300	5      5
10	400	5      5
10	500	5      5

11	100	5      4
11	200	5      4
11	300	5      5
11	400	5      5
11	500	5      5

12	100	5      4
12	200	5      4
12	300	5      5
12	400	5      5
12	500	5      5

13	100	5      4
13	200	5      4
13	300	5      5
13	400	5      5
13	500	5      5

14	100	5      4
14	200	6      4
14	300	6      5
14	400	6      5
14	500	6      5

Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: table

Post by Daniel Shawul »

Should Dann's depth be halved or something ? The R (r) he calculated is already multiplied by OnePly , then when doing recursion it will be multiplied by OnePly again. Originally he used depth without dividing by OnePly (which I think is 2) , so I think that will double the reduction depth :o If that is the case then it is going to be very aggressive.
#ifdef SMOOTH_REDUCTION
double delta = approximateEval - beta;
delta = max(delta, 1.0);
double ddepth = double(depth);
double r = 0.18 * ddepth + 3.1 + log(delta)/5.0;
r = r > ddepth ? ddepth : r;
int R = int(r);
#else
// Null move dynamic reduction based on depth
int R = (depth >= 5 * OnePly ? 4 : 3);

// Null move dynamic reduction based on value
if (approximateEval - beta > PawnValueMidgame)
R++;
#endif
nullValue = -search(pos, ss, -(beta-1), depth-R*OnePly, ply+1, false, threadID);
Last edited by Daniel Shawul on Tue Dec 29, 2009 7:14 pm, edited 1 time in total.
User avatar
Zach Wegner
Posts: 1922
Joined: Thu Mar 09, 2006 12:51 am
Location: Earth

Re: Smooth scaling stockfish

Post by Zach Wegner »

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
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Smooth scaling stockfish

Post by Tord Romstad »

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?
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: table

Post by mcostalba »

Daniel Shawul wrote:Should Dann's depth be halved or something ? The R (r) he calculated is already multiplied by OnePly , then when doing recursion it will be multiplied by OnePly again. Originally he used depth without dividing by OnePly (which I think is 2) , so I think that will double the reduction depth :o If that is the case then it is going to be very aggressive.
#ifdef SMOOTH_REDUCTION
double delta = approximateEval - beta;
delta = max(delta, 1.0);
double ddepth = double(depth);
double r = 0.18 * ddepth + 3.1 + log(delta)/5.0;
r = r > ddepth ? ddepth : r;
int R = int(r);
#else
// Null move dynamic reduction based on depth
int R = (depth >= 5 * OnePly ? 4 : 3);

// Null move dynamic reduction based on value
if (approximateEval - beta > PawnValueMidgame)
R++;
#endif
nullValue = -search(pos, ss, -(beta-1), depth-R*OnePly, ply+1, false, threadID);
Am I wrong or here for all the values where

Code: Select all

approximateEval <= beta
we have reduction R == 1 ??????

It means that when position evaluation is less then beta (very common case, more then 50% of cases) we don't have _any_ reduction but just a normal search ?????? :shock:

In this case Dann's logic is like to do _not_ do null move when position evaluation is less then beta :shock: :shock:
Dann Corbit
Posts: 12542
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Smooth scaling stockfish

Post by Dann Corbit »

Uri Blass wrote:
zamar wrote:+150elo???

If we can get even close to this, I think that this is really great news for whole chess community!!

Code: Select all

		double r = 0.18 * ddepth + 3.1 + log&#40;delta&#41;/5.0;
Balancing this equation is perhaps the next challenge? I need to think about this...
I think that it may be interesting to balance this equation also with
replacing approximateEval = quick_evaluate(pos) by something that is closer to the real evaluation or the real evaluation.

Even if evaluate(pos) is too expensive to calculate then it is not expensive to calculate average difference between quick_evaluate() and evaluate()
for the cases that evaluate() is being calculated and later use the average value for better approximation.

Uri
It would also be possible to do an IID like approch (IOW, search depth/2, depth-k, or something along those lines).
Dann Corbit
Posts: 12542
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Smooth scaling stockfish

Post by Dann Corbit »

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?
If you have a 64 bit PC, try this one (my previous posting of the JA build had a defect because I forgot to tell him to add macro definition for SMOOTH_SCALING):
http://cap.connx.com/chess-engines/new- ... 16s_ja.rar

I tested by play against the unmodified stockfish, with fast paced games. I only had 30 games, and so randomness is (of course) huge and it is entirely possible that there will be no improvement at all.
Dann Corbit
Posts: 12542
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Smooth scaling stockfish

Post by Dann Corbit »

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?
If you have a 64 bit PC, try this one (my previous posting of the JA build had a defect because I forgot to tell him to add macro definition for SMOOTH_SCALING):
http://cap.connx.com/chess-engines/new- ... 16s_ja.rar

I tested by play against the unmodified stockfish, with fast paced games. I only had 30 games, and so randomness is (of course) huge and it is entirely possible that there will be no improvement at all.
I seem to recall that you prefer a Mac. So use the search.cpp found in here:
http://cap.connx.com/chess-engines/new-approach/sfc.zip
{sfc stands for "stock fish changes"}

I guess that it will be better to do this:

Code: Select all

#ifdef SMOOTH_REDUCTION 
      double delta = approximateEval - beta; 
      delta = max&#40;delta, 1.0&#41;; 
      double ddepth = double&#40;depth&#41;; 
      double r = 0.18 * ddepth + 3.1 + log&#40;delta&#41;/5.0; 
      r = r > ddepth ? ddepth &#58; r; 
      int R = int&#40;r * OnePly&#41;; 
#else 
        // Null move dynamic reduction based on depth 
        int R = &#40;depth >= 5 * OnePly ? 4 &#58; 3&#41;; 

        // Null move dynamic reduction based on value 
        if &#40;approximateEval - beta > PawnValueMidgame&#41; 
            R++; 
        R *= OnePly;
#endif 
      nullValue = -search&#40;pos, ss, -&#40;beta-1&#41;, depth-R, ply+1, false, threadID&#41;; 
but I did not test it yet.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: table

Post by Daniel Shawul »

Or maybe not :) But i would recommend changing the formula

Code: Select all

double r = 0.18 * ddepth + 3.1 + log&#40;delta&#41;/5.0;
to

Code: Select all

double r = 0.09 * OnePly * ddepth + 3.1 + log&#40;delta&#41;/5.0;
or something similar to avoid confusion if one changes the value of OnePly say to 4 or 8.