Use of ttvalue as static evaluation

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Fabio Gobbato
Posts: 217
Joined: Fri Apr 11, 2014 10:45 am
Full name: Fabio Gobbato

Use of ttvalue as static evaluation

Post by Fabio Gobbato »

When is correct to use the ttvalue as static evaluation without calling the evaluation function?

The ttvalue is not returned to the lower level if (ttdepth<depth) or (ttnode==CUTNODE && ttvalue<beta) or (ttnode==ALLNODE && ttvalue>alpha).

if ttdepth<depth && ttnode==PVNODE I have an exact score and I can use as static evaluation without problems but in the other cases It's better to call the evaluation function or it's good to use a lower or upper bound without calling the evaluation?
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: Use of ttvalue as static evaluation

Post by elcabesa »

I could be wrong, but it looks to me that Stockfish always call eval function and after it try to refine eval with ttvalue.

Code: Select all

if &#40;ttValue != VALUE_NONE&#41;
    if &#40;tte->bound&#40;) & &#40;ttValue > eval ? BOUND_LOWER &#58; BOUND_UPPER&#41;)
      eval = ttValue;
User avatar
Fabio Gobbato
Posts: 217
Joined: Fri Apr 11, 2014 10:45 am
Full name: Fabio Gobbato

Re: Use of ttvalue as static evaluation

Post by Fabio Gobbato »

Code: Select all

	// TT lookup
	uint64_t key = get_key&#40;B&#41;;
	hash_t *tte = tt_find&#40;key&#41;;
	if &#40;tte&#41; &#123;
		if &#40;tte->depth > 0&#41;
			si->tt = tte->move;
		current_eval = tte->eval;
		if &#40;ply > 0 && can_return_tt&#40;is_pv, tte, depth, beta, ply&#41;) &#123;
			tt_refresh&#40;tte&#41;;
			return adjust_tt_score&#40;tte->score, ply&#41;;
		&#125;
	&#125; else
		current_eval = in_check ? -INF &#58; calc_eval&#40;B&#41;;
This is the same idea in DiscoCheck and it seems it always uses the tteval without calling the evaluation.
It seems correct to me to use only a PVNODE eval
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: Use of ttvalue as static evaluation

Post by elcabesa »

Hi fabio, I don't understand your post.

in the code you posted from discocheck it looks like tte->eval if the result of calc_eval(B) saved in TT.
so it simply avoid a calc_eval call because it has previously saved the result in the TT.

The code i posted is from stckfish and it is eval refinement, it replace static-eval with result of search
User avatar
Fabio Gobbato
Posts: 217
Joined: Fri Apr 11, 2014 10:45 am
Full name: Fabio Gobbato

Re: Use of ttvalue as static evaluation

Post by Fabio Gobbato »

It seems to me that stockfish and discocheck use a similar idea. In the code from discocheck curret_eval = tte->eval if there is a tt hit. Else current_eval is the result from calc_eval(). Where current_eval is the static evaluation of the position used for pruning decisions.

I don't understand at all why is a good thing to update always static eval with the ones in the tt entry.
If the tt entry is a lower or upper bound you could have a big difference between this value and a good one, maybe in this cases it's good to update the static evaluation making a call to the evaluation function .
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: Use of ttvalue as static evaluation

Post by elcabesa »

you don't understand :)

in discocheck tte->score is the score of the search, which could be exact result, a lower bound or an higher bound

tte->eval is the result of calc_eval(B)

he saves both score and static eval in the Trasposition table!!