Author: Tony Werten
Date: 00:58:59 06/26/03
Go up one level in this thread
On June 25, 2003 at 19:48:37, Geoff wrote:
>Hello
>
Hi,
I've had some problems with this as well. My solution ( wich may be the safest
):
Create a new flag for your hashtable. So beside EXACT, AT_MOST, AT_LEAST, create
a CHECKMATE.
Now, if search returns a score (and it is not a bound !!), fe 9993 at ply 5, you
store in the hashtable CHECKMATE_SCORE-(score+depth) with the CHECKMATE flag. (
switch some stuff for being checkmated )
Whenever you retrieve an entry, fe -2, you get the score back: minus, so you are
being checkmated, -CHECKMATE_SCORE-score+depth.
In case of +2, CHECKMATE_SCORE-score-depth.
To check for bounds (wich may be the point where your implementation goes wrong
) if score>9000 (so probably a checkmate) score has to be > alfa as well. If
score < -9000 then score has to be < beta. If you don't do this, your window for
the next search might screw things up (always returning checkmates).
For who's interested: At the dutch championships I was playing ANT and I had a
won game, but the score returned from hashtable was not corrected for depth (at
1 place), so search returned checkmate in 0. In case of equal scores, my engine
pickes the one with the most moves :( After queening 3 pawns, it let my opponent
queen as well ( more moves, so better ) With 3 queens against 1 my engine still
refused to checkmate and I lost on time :(
Tony
>I have been adding hashing to my work in progress engine. It didn't take me too
>long to get implemented except I have one nasty bug I don't really understand.
>
>The annoying part is that I read several messages in the archive explaining how
>to correctly store mate scores in the hash table. Despite this it is still very
>buggy when I enable storing mate scores, throwing away easy wins to 3 fold
>repetition draws.
>
>
>Essentially I add or subtact ply to the mate score before storing in the table,
>this should store it relative to this current position not relative to the
>root. See code below
>
>Note I am only adjusting an exact score and leaving a low or high score
>unadjusted. Not sure if this is correct?
>
>#define CHECKMATE = 10,000
>
>BOOL hashInsert(U64 hashCode, S32 eval, move bestMove, S32 depth, U8 flags)
>{
> pHashEntry ph;
>
> ph = PHASH_ENTRY(hashCode);
>
> if ((ph->code != hashCode) &&
> ((ph->flags & VALIDITY_FLAG_MASK) == VALID_FLAG) &&
> (ph->depth > depth))
> return FALSE;
>
> /* Adjust mate scores so they are relative to this position */
> if (eval > (INFINITY - MAX_PLY)) /* > 9,900 */
> {
> if ((ph->flags & BOUNDS_MASK) == EXACT_FLAG)
> {
> printfDebug("Big Eval ply = %d depth = %d evalBefore = %d, evalAfter =
>%d\r\n", ply, depth, eval, eval + ply);
> eval = eval + ply;
> }
> }
> else if (eval < (-INFINITY + MAX_PLY)) /* < -9,900 */
> {
> if ((ph->flags & BOUNDS_MASK) == EXACT_FLAG)
> eval = eval - ply;
>
>
>/* Add info to the table */
>etc etc
>
>Then when this position is found again later at some other ply, the ply is
>either adder or subtracted to get the correct mate in x from the root position
>
>
>Running this code with search depth 8, I get for example
>
>Big Eval ply = 5 depth = 0 evalBeforeAdjust = 9993, evalAfterAdjust = 9998
>
>I read this as we found a mate for us that is 7 ply from the root, but we
>discovered it at ply 5 of our search, so it is in fact 7 - 5 ply down from this
>current position hence store CHECKMATE-2 in the hash table.
>
>The other output I get from this test was as below, I dont really understand
>this it is saying I think, that at the leaf node (depth 8) we have found a mate
>in the q search at 5 ply from the root ?????? This then causes the adjustment to
>store CHECKMATE+3 in the hash table. Is this possible or a bug ?
>
>Big Eval ply = 8 depth = 0 evalBeforeAdjust = 9995, evalAfterAdjust = 10003
>
>
>Clear as mud huh ? ;-)
>
>Any help in explaining what is happening here or spotting my misunderstanding
>would be much appreciated. Thanks guys !
>
> Regards Geoff
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.