Nasty Vicki bug...

Discussion of chess software programming and technical issues.

Moderator: Ras

sparky

Nasty Vicki bug...

Post by sparky »

Hi all

I've finally added transposition tables, history heuristics and bunch of other stuff to my engine. It clearly plays better, but I have a nasty bug that I just cannot pin down!

Vicki gets into a mate-in-x position, but instead of mating it goes into a draw by repetition. This only happens occasionally, which make me wonder if this isn't something to do with the transposition table?

Has anyone had this before?

Thanks

(Also, I'm having difficulty to post. I keep on getting:
Parse error: syntax error, unexpected T_BOOLEAN_AND in /usr/local/apache/htdocs/talkchess.com/forum/posting.php on line 505)
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Nasty Vicki bug...

Post by hgm »

It seems you do not handle mate scores consistently, so that storing them in the hash, and later retrieving them at another level in the tree, does produce a different score from when you would have found the same mate at that new place in the tree through search.
pijl

Re: Nasty Vicki bug...

Post by pijl »

hgm wrote:It seems you do not handle mate scores consistently, so that storing them in the hash, and later retrieving them at another level in the tree, does produce a different score from when you would have found the same mate at that new place in the tree through search.
There are basically two ways to solve this:
- correct the score in the hashtable to be the distance to mate of the hashed position (instead of the root position) and correct it back to the distance to mate from the root when retrieving the score
- Don't bother about storing exact mate scores and just use a lower (or upper, depending on mating or being mated) bound for mates, e.g. lowerbound with mate in at most 1000 moves.

I've used the first method in the Baron, and use the second method now in CTD.
Richard.
sparky

Re: Nasty Vicki bug...

Post by sparky »

Thanks guys - I'll implmement this and hopefully I'll turn more of artificial draws into mates. The new version of Vicki may actually breech the 2000 elo level!
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Nasty Vicki bug...

Post by hgm »

pijl wrote:There are basically two ways to solve this:
- correct the score in the hashtable to be the distance to mate of the hashed position (instead of the root position) and correct it back to the distance to mate from the root when retrieving the score
- Don't bother about storing exact mate scores and just use a lower (or upper, depending on mating or being mated) bound for mates, e.g. lowerbound with mate in at most 1000 moves.
Actually my engines solve this through a delayed-loss bonus, which is different (and more general) from both methods you mention:

Code: Select all

Search(alpha, beta)
{
    probeHash(); if(HIT) return(hash->score);

    if(alpha < LOSS) alpha--;
    if(beta <= LOSS) beta--;

    bestScore = alpha; // for fail hard; you could also do fail soft.

    for(ALL_MOVES)
    {
        score = - Search(-beta, -alpha);
        if(score > bestScore) bestScore = score;
        .... // usual alpha-beta stuff
    }
    
    if(bestScore < LOSS) bestScore++; // soften a loss if it occurs on your own move
    storeHash(bestScore);
    return bestScore;
}
LOSS gives the limit for the magnitude of the loss for which you think it is worth delaying it as much as you can. you could set it to -MATESCORES, to delay only mates. Or you could set it to currentEval to delay any loss.