SF 2.0.1 - update_gains on TT hit?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Ralph Stoesser
Posts: 408
Joined: Sat Mar 06, 2010 9:28 am

SF 2.0.1 - update_gains on TT hit?

Post by Ralph Stoesser »

Ever thought about (or even tried) to update a move's positional gain before you return from a TT hit? The below code snippet would be for search(). It would be consistent to do it in qsearch() also. Since you update the current move from previous ply, I think it should make sense to update the gain before you return.

Code: Select all

    if (!PvNode && tte && ok_to_use_TT(tte, depth, beta, ply))
    {
        TT.refresh(tte);
        ss->bestMove = ttMove; // Can be MOVE_NONE
        if (!isCheck)
        	update_gains(pos, (ss-1)->currentMove, (ss-1)->eval, tte->static_value());
        return value_from_tt(tte->value(), ply);
    }
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: SF 2.0.1 - update_gains on TT hit?

Post by zamar »

Ralph Stoesser wrote:Ever thought about (or even tried) to update a move's positional gain before you return from a TT hit? The below code snippet would be for search(). It would be consistent to do it in qsearch() also. Since you update the current move from previous ply, I think it should make sense to update the gain before you return.

Code: Select all

    if (!PvNode && tte && ok_to_use_TT(tte, depth, beta, ply))
    {
        TT.refresh(tte);
        ss->bestMove = ttMove; // Can be MOVE_NONE
        if (!isCheck)
        	update_gains(pos, (ss-1)->currentMove, (ss-1)->eval, tte->static_value());
        return value_from_tt(tte->value(), ply);
    }
I'll add this to our testing queue. I don't expect ELO increase, but you never know...
Joona Kiiski
Ralph Stoesser
Posts: 408
Joined: Sat Mar 06, 2010 9:28 am

Re: SF 2.0.1 - update_gains on TT hit?

Post by Ralph Stoesser »

I also don't expect an Elo increase, only maybe at very fast tc. But better test a useless tweak here and there than endlessly talk about Rybka cloning...

A remark regarding the update_gains() call in search()

Code: Select all

    // Step 5. Evaluate the position statically and
    // update gain statistics of parent move.
    if (isCheck)
        ss->eval = ss->evalMargin = VALUE_NONE;
    else if (tte)
    {
        assert(tte->static_value() != VALUE_NONE);

        ss->eval = tte->static_value();
        ss->evalMargin = tte->static_value_margin();
        refinedValue = refine_eval(tte, ss->eval, ply);
    }
    else
    {
        refinedValue = ss->eval = evaluate(pos, ss->evalMargin);
        TT.store(posKey, VALUE_NONE, VALUE_TYPE_NONE, DEPTH_NONE, MOVE_NONE, ss->eval, ss->evalMargin);
    }

    // Save gain for the parent non-capture move
    update_gains(pos, (ss-1)->currentMove, (ss-1)->eval, ss->eval);
Similar to the code in qsearch() the update_gains() function could be called only if not in check

Code: Select all

    // Step 5. Evaluate the position statically and
    // update gain statistics of parent move.
    if (isCheck)
        ss->eval = ss->evalMargin = VALUE_NONE;
    else 
    {
        if (tte)
        {
            assert(tte->static_value() != VALUE_NONE);

            ss->eval = tte->static_value();
            ss->evalMargin = tte->static_value_margin();
            refinedValue = refine_eval(tte, ss->eval, ply);
        }
        else
        {
            refinedValue = ss->eval = evaluate(pos, ss->evalMargin);
            TT.store(posKey, VALUE_NONE, VALUE_TYPE_NONE, DEPTH_NONE, MOVE_NONE, ss->eval, ss->evalMargin);
        }

        // Save gain for the parent non-capture move
        update_gains(pos, (ss-1)->currentMove, (ss-1)->eval, ss->eval);
   }
Saves a few unneccesary function calls.