"stat score bonus" in stockfish

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

"stat score bonus" in stockfish

Post by xr_a_y »

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: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: "stat score bonus" in stockfish

Post by Joost Buijs »

I think the explanation is: 'because it tested 0.3 Elo better'.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: "stat score bonus" in stockfish

Post by xr_a_y »

Joost Buijs wrote: Sat Nov 02, 2019 10: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: 91
Joined: Sat Nov 02, 2019 6:42 pm
Full name: ɹǝƃɹǝqǝᗡ ǝɔnɹꓭ

Re: "stat score bonus" in stockfish

Post by Deberger »

xr_a_y wrote: Sat Nov 02, 2019 10:55 am
Joost Buijs wrote: Sat Nov 02, 2019 10: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: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: "stat score bonus" in stockfish

Post by xr_a_y »

Thanks for the details
abulmo2
Posts: 433
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: "stat score bonus" in stockfish

Post by abulmo2 »

Deberger wrote: Sun Nov 03, 2019 5: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: 4567
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: "stat score bonus" in stockfish

Post by Eelco de Groot »

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