"stat score bonus" in stockfish

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
User avatar
xr_a_y
Posts: 768
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

"stat score bonus" in stockfish

Post by xr_a_y » Fri Nov 01, 2019 10:00 pm

Regarding this code

Code: Select all

    // Step 6. Static evaluation of the position
    if (inCheck) {
        ss->staticEval = eval = VALUE_NONE;
        improving = false;
        goto moves_loop;  // Skip early pruning when in check
    }
    else if (ttHit) {
        // Never assume anything about values stored in TT
        ss->staticEval = eval = tte->eval();
        if (eval == VALUE_NONE)
            ss->staticEval = eval = evaluate(pos);
        if (eval == VALUE_DRAW)
            eval = value_draw(thisThread);
        // Can ttValue be used as a better position evaluation?
        if (    ttValue != VALUE_NONE && (tte->bound() & (ttValue > eval ? BOUND_LOWER:BOUND_UPPER)))
            eval = ttValue;
    }
    else{
        if ((ss-1)->currentMove != MOVE_NULL) {
            int bonus = -(ss-1)->statScore / 512;
            ss->staticEval = eval = evaluate(pos) + bonus;
        }
        else
            ss->staticEval = eval = -(ss-1)->staticEval + 2 * Eval::Tempo;
        tte->save(posKey, VALUE_NONE, ttPv, BOUND_NONE, DEPTH_NONE, MOVE_NONE, eval);
    }
  
I am looking for an explanation of the very little "bonus" added only if evaluate is called and ttHit is false.
Why here ? why only here (and not also when ttHit with VALUE_NONE ?

Joost Buijs
Posts: 987
Joined: Thu Jul 16, 2009 8:47 am
Location: Almere, The Netherlands

Re: "stat score bonus" in stockfish

Post by Joost Buijs » Sat Nov 02, 2019 9:23 am

I think the explanation is: 'because it tested 0.3 Elo better'.

User avatar
xr_a_y
Posts: 768
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

Re: "stat score bonus" in stockfish

Post by xr_a_y » Sat Nov 02, 2019 9:55 am

Joost Buijs wrote:
Sat Nov 02, 2019 9:23 am
I think the explanation is: 'because it tested 0.3 Elo better'.
But there is always a real idea before the test try :)

User avatar
Deberger
Posts: 5
Joined: Sat Nov 02, 2019 5:42 pm
Full name: ɹǝƃɹǝqǝᗡ ǝɔnɹꓭ

Re: "stat score bonus" in stockfish

Post by Deberger » Sun Nov 03, 2019 4:26 am

xr_a_y wrote:
Sat Nov 02, 2019 9:55 am
Joost Buijs wrote:
Sat Nov 02, 2019 9:23 am
I think the explanation is: 'because it tested 0.3 Elo better'.
But there is always a real idea before the test try :)
The (real) idea is to give a bonus if the previous move of the opponent was historically bad,
and a penalty if the previous move of the opponent was historically good.

The Idea, Tweaked, Simplified

At this point, I wouldn't be surprised if there was more Elo gain by removing it altogether. :-)

User avatar
xr_a_y
Posts: 768
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

Re: "stat score bonus" in stockfish

Post by xr_a_y » Sun Nov 03, 2019 8:05 am

Thanks for the details

abulmo2
Posts: 199
Joined: Fri Dec 16, 2016 10:04 am
Contact:

Re: "stat score bonus" in stockfish

Post by abulmo2 » Sun Nov 03, 2019 10:50 am

Deberger wrote:
Sun Nov 03, 2019 4:26 am
The (real) idea is to give a bonus if the previous move of the opponent was historically bad,
and a penalty if the previous move of the opponent was historically good.
Is not the bonus added recursively? It looks to me that the result is to inflate deep score. Maybe it adds confidence to score returns from deeper searches.
Richard Delorme

User avatar
Eelco de Groot
Posts: 4162
Joined: Sun Mar 12, 2006 1:40 am
Location: Groningen

Re: "stat score bonus" in stockfish

Post by Eelco de Groot » Sun Nov 03, 2019 3:01 pm

I think there is an aging factor for the stat scores, so that they do get refreshed. But more importantly, the bonus is only added in nodes with no ttHit. This means probably that the node is often near the leaves, and a new node. Once the hash probe finds a search result, you have both a search result and a static evaluation, and the static evaluation is modified with that if possible for use with nullmove etc.
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

Post Reply