pawn hash and eval tuning

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

pawn hash and eval tuning

Post by jwes »

How do people handle pawn hash when tuning? It just occurred to me if I have a pawn hash, then 99% of the time I won't have pawn terms to tune.
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: pawn hash and eval tuning

Post by Desperado »

Hi,

you can simply always compute the data when in tuning mode, like...

Code: Select all

pawn_t* PawnTable::getSlot(Position* pos)
{
    pawn_t* slot = &table[getKey(pos) & _HASHMASK];

    if( NOT_TUNING )
    if(BitUtil::hi32(getKey(pos)) == slot->lock) {
        return slot;
    }

    evaluate(pos,slot);
    return slot;
}
At least if the tuning algorithm is not sensitive to speed of the engine and you are talking of parameter tuning.
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: pawn hash and eval tuning

Post by tpetzke »

This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
Thomas...

=======
http://macechess.blogspot.com - iCE Chess Engine
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: pawn hash and eval tuning

Post by Desperado »

tpetzke wrote:This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
For example if you have set 100 cp for a passed pawn but change the value to 105 cp you need to compute the outcome again. Otherwise you would retrieve the score which was computed with 100 cp.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: pawn hash and eval tuning

Post by bob »

jwes wrote:How do people handle pawn hash when tuning? It just occurred to me if I have a pawn hash, then 99% of the time I won't have pawn terms to tune.
Not quite. 99% of the time you won't have to COMPUTE the pawn scores, but you use them at every terminal node... So the tuning is the same whether you hash or not.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: pawn hash and eval tuning

Post by bob »

Desperado wrote:
tpetzke wrote:This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
For example if you have set 100 cp for a passed pawn but change the value to 105 cp you need to compute the outcome again. Otherwise you would retrieve the score which was computed with 100 cp.
Pawn hash doesn't survive program termination. You play a game, or test a position, then it would be cleared, at least when using games for testing. If you are talking about some sort of automated annealing or whatever, then you would likely want to disable it.
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: pawn hash and eval tuning

Post by jdart »

For this reason I disable caching when tuning.

See https://github.com/jdart1/arasan-chess/ ... /scoring.h.

The evaluation function takes a boolean parameter:

Code: Select all

// evaluate "board" from the perspective of the side to move.
int evalu8( const Board &board, bool useCache = true );
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: pawn hash and eval tuning

Post by Desperado »

bob wrote:
Desperado wrote:
tpetzke wrote:This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
For example if you have set 100 cp for a passed pawn but change the value to 105 cp you need to compute the outcome again. Otherwise you would retrieve the score which was computed with 100 cp.
Pawn hash doesn't survive program termination. You play a game, or test a position, then it would be cleared, at least when using games for testing. If you are talking about some sort of automated annealing or whatever, then you would likely want to disable it.
Well, the tuning method needs to be specified for the original post.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: pawn hash and eval tuning

Post by mar »

Desperado wrote:I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
Well, you run n threads on million(s) of positions for tuning, one run of course has the same parameters. Naturally you flush the caches between runs, I don't see any problem here.
Eval cache speeds up Texel tuning a lot, at least in my case it did.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: pawn hash and eval tuning

Post by bob »

Desperado wrote:
bob wrote:
Desperado wrote:
tpetzke wrote:This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
For example if you have set 100 cp for a passed pawn but change the value to 105 cp you need to compute the outcome again. Otherwise you would retrieve the score which was computed with 100 cp.
Pawn hash doesn't survive program termination. You play a game, or test a position, then it would be cleared, at least when using games for testing. If you are talking about some sort of automated annealing or whatever, then you would likely want to disable it.
Well, the tuning method needs to be specified for the original post.
This is cache 101. If something invalidates the data, it can't be used again. If you allow the score weights to change, you have to take action. I would think that's pretty obvious...

Same problem with position learning. If ANYTHING changes, old position learning should be invalidated.