a way to prevent broken PV's when using hash tables...

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

sluijten
Posts: 44
Joined: Wed Apr 13, 2011 12:43 pm

a way to prevent broken PV's when using hash tables...

Post by sluijten »

I noticed that the percentage of exact entries in the hash table is quite low, this technique will not break the PV: only use null-move cut-offs and beta cut-offs from the hash table. You can still store exact results, but only use them for move ordering.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: a way to prevent broken PV's when using hash tables...

Post by bob »

sluijten wrote:I noticed that the percentage of exact entries in the hash table is quite low, this technique will not break the PV: only use null-move cut-offs and beta cut-offs from the hash table. You can still store exact results, but only use them for move ordering.
That will hurt more in endgames than you suspect. And it hurts somewhat overall, or you would never see a short PV in the first place...
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: a way to prevent broken PV's when using hash tables...

Post by lucasart »

bob wrote:
sluijten wrote:I noticed that the percentage of exact entries in the hash table is quite low, this technique will not break the PV: only use null-move cut-offs and beta cut-offs from the hash table. You can still store exact results, but only use them for move ordering.
That will hurt more in endgames than you suspect. And it hurts somewhat overall, or you would never see a short PV in the first place...
I also do the the same. So how do solve the 3 move problem if you use htable pruning at PV nodes ?
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: a way to prevent broken PV's when using hash tables...

Post by hgm »

3 move problem?

You can pry the PV out of the hash table, or hash the entire PV in a separate table or overflow entry.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: a way to prevent broken PV's when using hash tables...

Post by bob »

lucasart wrote:
bob wrote:
sluijten wrote:I noticed that the percentage of exact entries in the hash table is quite low, this technique will not break the PV: only use null-move cut-offs and beta cut-offs from the hash table. You can still store exact results, but only use them for move ordering.
That will hurt more in endgames than you suspect. And it hurts somewhat overall, or you would never see a short PV in the first place...
I also do the the same. So how do solve the 3 move problem if you use htable pruning at PV nodes ?
First, describe the specific problem. If it is a short PV, then you can look at what I do to hash the PATH below an exact entry so that it can be grafted onto the PV when you get an EXACT hit.

If you are concerned about repetitions, and missing them because of a hit, or seeing them where you should not, you can't do a thing about it. You also get wrong hash results on non-EXACT entries. I don't see any reason to weaken an engine just to try to hide a _perceived_ problem...
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: a way to prevent broken PV's when using hash tables...

Post by lucasart »

bob wrote:
lucasart wrote:
bob wrote:
sluijten wrote:I noticed that the percentage of exact entries in the hash table is quite low, this technique will not break the PV: only use null-move cut-offs and beta cut-offs from the hash table. You can still store exact results, but only use them for move ordering.
That will hurt more in endgames than you suspect. And it hurts somewhat overall, or you would never see a short PV in the first place...
I also do the the same. So how do solve the 3 move problem if you use htable pruning at PV nodes ?
First, describe the specific problem. If it is a short PV, then you can look at what I do to hash the PATH below an exact entry so that it can be grafted onto the PV when you get an EXACT hit.

If you are concerned about repetitions, and missing them because of a hit, or seeing them where you should not, you can't do a thing about it. You also get wrong hash results on non-EXACT entries. I don't see any reason to weaken an engine just to try to hide a _perceived_ problem...
displaying a full PV is the least of my concerns. What I was worried about is the 3 repetition problem.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: a way to prevent broken PV's when using hash tables...

Post by bob »

lucasart wrote:
bob wrote:
lucasart wrote:
bob wrote:
sluijten wrote:I noticed that the percentage of exact entries in the hash table is quite low, this technique will not break the PV: only use null-move cut-offs and beta cut-offs from the hash table. You can still store exact results, but only use them for move ordering.
That will hurt more in endgames than you suspect. And it hurts somewhat overall, or you would never see a short PV in the first place...
I also do the the same. So how do solve the 3 move problem if you use htable pruning at PV nodes ?
First, describe the specific problem. If it is a short PV, then you can look at what I do to hash the PATH below an exact entry so that it can be grafted onto the PV when you get an EXACT hit.

If you are concerned about repetitions, and missing them because of a hit, or seeing them where you should not, you can't do a thing about it. You also get wrong hash results on non-EXACT entries. I don't see any reason to weaken an engine just to try to hide a _perceived_ problem...
displaying a full PV is the least of my concerns. What I was worried about is the 3 repetition problem.
There is _nothing_ you can do about that. Ignoring EXACT hits doesn't help a bit, because you still trust the fail-hi/fail-lo entries and they suffer from the same problem. Failing low or high because of either an overlooked repetition, or because you see an incorrect repetition score, is just as damaging.

This is a problem not worth worrying about. There is one well-known solution, that of not allowing matches when draft >= depth, and restrict it to draft == depth. But that is a performance-killer and will hurt more than it helps, from actual test measurements.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: a way to prevent broken PV's when using hash tables...

Post by lucasart »

bob wrote:
lucasart wrote:
bob wrote:
lucasart wrote:
bob wrote:
sluijten wrote:I noticed that the percentage of exact entries in the hash table is quite low, this technique will not break the PV: only use null-move cut-offs and beta cut-offs from the hash table. You can still store exact results, but only use them for move ordering.
That will hurt more in endgames than you suspect. And it hurts somewhat overall, or you would never see a short PV in the first place...
I also do the the same. So how do solve the 3 move problem if you use htable pruning at PV nodes ?
First, describe the specific problem. If it is a short PV, then you can look at what I do to hash the PATH below an exact entry so that it can be grafted onto the PV when you get an EXACT hit.

If you are concerned about repetitions, and missing them because of a hit, or seeing them where you should not, you can't do a thing about it. You also get wrong hash results on non-EXACT entries. I don't see any reason to weaken an engine just to try to hide a _perceived_ problem...
displaying a full PV is the least of my concerns. What I was worried about is the 3 repetition problem.
There is _nothing_ you can do about that. Ignoring EXACT hits doesn't help a bit, because you still trust the fail-hi/fail-lo entries and they suffer from the same problem. Failing low or high because of either an overlooked repetition, or because you see an incorrect repetition score, is just as damaging.

This is a problem not worth worrying about. There is one well-known solution, that of not allowing matches when draft >= depth, and restrict it to draft == depth. But that is a performance-killer and will hurt more than it helps, from actual test measurements.
OK I am now testing the following TT pruning:
static inline bool can_return_tt(const TTEntry *tte, int depth, int alpha, int beta, int ply)
{
int tt_score = adjust_tt_score(tte->score, ply);

if (tte->type == ScoreExact)
// NB: if ply == 0, we don't want TT depth > depth, because of the 3 move rule
return (ply ? tte->depth >= depth : tte->depth == depth)
&& alpha < tt_score && tt_score < beta;
else
return (tte->depth >= depth
|| tt_score >= max(mate_in(MAX_PLY), beta)
|| tt_score < min(mated_in(MAX_PLY), beta))
&& ( (tte->type == ScoreLbound && tt_score >= beta)
|| (tte->type == ScoreUbound && tt_score <= alpha));
}
versus my previous one, which is the same but discarding the ScoreExact case (which inevitable comes from PV nodes, and onl;y prunes when encountered at PV nodes)

I'll probably need 200 games to decide, played 20 so far...
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: a way to prevent broken PV's when using hash tables...

Post by tpetzke »

>>displaying a full PV is the least of my concerns. What I was worried about is the 3 repetition problem.

IMO you should have a 3 fold repetition detection that doesn't rely on a hash table. Before you probe the hash table you check for a repeated position (1 repetition is enough) and just return a draw or contempt score if it is repeated.

In such a case the hash table isn't probed at all and whatever is stored there doesn't interfere with the DRAWish evaluation of that node in the current path.

Thomas...
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: a way to prevent broken PV's when using hash tables...

Post by lucasart »

tpetzke wrote:>>displaying a full PV is the least of my concerns. What I was worried about is the 3 repetition problem.

IMO you should have a 3 fold repetition detection that doesn't rely on a hash table. Before you probe the hash table you check for a repeated position (1 repetition is enough) and just return a draw or contempt score if it is repeated.

In such a case the hash table isn't probed at all and whatever is stored there doesn't interfere with the DRAWish evaluation of that node in the current path.

Thomas...
Yes, that's one way to avoid the problem. Another way would be to zobrist into the key the number of times which the position was repeated, and then you can use htable as much as you like, and never have to think about 3 repetition in the htable code :)