How do you handle draw scores by repetition and fifty move rule in TT?
I use zero as draw score, and simply prevent to load such an value from TT,
i guess there are better techniques to prevent an mix up with an eval score of zero.
--
Srdja
edit: assuming i wish to use an 16 bit signed integer as tt score with centi pawn based eval.
Draw scores in TT
Moderator: Ras
-
- Posts: 3116
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
-
- Posts: 1872
- Joined: Sat Nov 25, 2017 2:28 pm
- Location: France
Re: Draw scores in TT
Hello,
using a reversible 16bit hash for move in TT (I store this move hash in a TT entry), I can simply check afterward if the move is leading to a draw and eventually use the contempt factor or just skip the TT advice and search for a best move.
using a reversible 16bit hash for move in TT (I store this move hash in a TT entry), I can simply check afterward if the move is leading to a draw and eventually use the contempt factor or just skip the TT advice and search for a best move.
-
- Posts: 3116
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: Draw scores in TT
Are 16 bit sufficient for a move? Hash collisions?using a reversible 16bit hash for move in TT
--
Srdja
Re: Draw scores in TT
Just curious but why would you want to prevent those scores in the TT?
They're valid for the position, aren't they?
They're valid for the position, aren't they?
-
- Posts: 1872
- Joined: Sat Nov 25, 2017 2:28 pm
- Location: France
Re: Draw scores in TT
Yes I just store starting square, landing square and a move type.
Something like this :
Something like this :
Code: Select all
class Move{
public :
[...]
typedef unsigned short int HashType;
static inline Square::LightSquare Hash2From(HashType h) { return (h >> 10) & 0x3F ;}
static inline Square::LightSquare Hash2To (HashType h) { return (h >> 4) & 0x3F ;}
static inline UtilMove::eSpecialMove Hash2Type(HashType h) { return UtilMove::eSpecialMove( (h & 0xF)+UtilMove::sm_mini);}
static inline HashType ToHash(Square::LightSquare from,
Square::LightSquare to,
UtilMove::eSpecialMove type){
if (type == UtilMove::sm_invalide) {
from = 0;
to = 0;
}
return (from << 10) | (to << 4) | (type-UtilMove::sm_mini);
}
static inline MiniMove HashToMini(HashType h) { return { Hash2From(h), Hash2To(h), Hash2Type(h) }; }
explicit Move(const MiniMove & mini);
[...]
};
-
- Posts: 3116
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: Draw scores in TT
Hmm, maybe i am just chasing rabbits here,Just curious but why would you want to prevent those scores in the TT?
They're valid for the position, aren't they?
but I think they are actual not valid for transpositions.
Repetition and fifty move rule are history based,
a transposition may have another history,
so the drawscore may be invalid.
I had recently some issues with Kaufmann pos 12
6k1/p3q2p/1nr3pB/8/3Q1P2/6P1/PP5P/3R2K1 b - - bm Rd6; id "position 12";
But now i can't reproduce the behavior anymore,
and storing and loading TT draw scores turns out to be an speedup.
--
Srdja
-
- Posts: 5667
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Draw scores in TT
There is no way to do it right (without encoding the history of the position into the hashkey, which will heavily impact Elo), so "everybody" just accepts the problems.smatovic wrote:How do you handle draw scores by repetition and fifty move rule in TT?
I use zero as draw score, and simply prevent to load such an value from TT,
i guess there are better techniques to prevent an mix up with an eval score of zero.
Not using draw scores from the TT, or not using special "draw-by-repetition" scores from the TT, does not help much since the path-dependent draw anyway has to be backed up to parent nodes whose scores can then be non-zero but still be influenced by the path-dependent draw. So not using draw scores is a "fake" solution.
This is called the Graph History Interaction problem. If you google it, you find an article titled "a general solution to the graph history interaction problem", but the title is severely misleading.
-
- Posts: 5667
- Joined: Tue Feb 28, 2012 11:56 pm
-
- Posts: 28314
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Draw scores in TT
If you really want to make a carreer out of this, you could keep track of which nodes are 'contaminated' by repetition scores. Unfortunately this is not very easy to detect. If a node has a move that is a repetition, and the repetion turns out to be best, it is obviously contaminated. But if the draw score is not best, it could still be contaminated, for when the move had not lead to a repetition its score might actually have been best. But nodes can only be repetitions if their position occurred on the branch closer to the root. (For repeating game positions there is no path dependence, and these are hard draws.) And that means they are currently being searched, at several ply higher depth than in their repetition. Which means a previous depth higher than what you need now should be available as an IID result or from their hash hit. From that score you can see how the draw score compares to their intrinsic score, and how the intrinsic score compares to the score of the best move in the current node, and thus if the repeat has contaminated the node. If it did, you could pass the uncontaminated score to the parent node, so that it can decide whether substituting the actual score for the uncontaminated score has contaminated it as well.
-
- Posts: 3116
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: Draw scores in TT
nevermind, KISS.If you really want to make a carreer out of this
--
Srdja