Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: The Code for the Rybka-Mate-Bug

Author: Vasik Rajlich

Date: 00:23:46 12/14/05

Go up one level in this thread


On December 13, 2005 at 08:47:51, Chrilly Donninger wrote:

>Just for the curious, below is the code for the Rybka-Mate bug. I have seen
>another bug in the Beta-Code too. There are in every programm hundreds of bugs,
>so it would be more surprising to say: I have seen no other bug.
>
>.text:0040CD07                 mov     ebp, [esp+868h+var_854]
>.text:0040CD0B                 cmp     ebp, 0FFFF810Ch
>.text:0040CD11                 mov     dword_667A14, edi
>.text:0040CD17                 jnz     loc_40CDCA
>.text:0040CD1D                 mov     eax, [esp+868h+arg_C]
>.text:0040CD24                 neg     al
>.text:0040CD26                 pop     edi
>.text:0040CD27                 pop     ebx
>.text:0040CD28                 pop     esi
>.text:0040CD29                 pop     ebp
>.text:0040CD2A                 sbb     eax, eax
>.text:0040CD2C                 and     eax, 0FFFF8300h
>.text:0040CD31                 add     esp, 858h
>.text:0040CD37                 retn
>
>In C this reads as:
>if(Bestscore == -32500( // No legal move found
>   if(InCheck) {
>      return -32000;
>   }
>   else { // Stalemate
>      return 0;
>   }
>}
>
>The bug is, that all mates are the same. In fact shorter mates are better for
>the mate-giving side (or worse for the mated side) than longer mates. One has to
>subtract the Plies/Distance from the starting position.
>The bug is in my opinion a consequence of a bad design decision. There are 2
>different "minus-infinite" values. In BestScore minus infinite is -32500, for
>mate its -32000. If one sets bestscore at the first place to -32000+Ply one gets
>cleaner and more efficient code and avoids the bug.
>I had the same bug in Nimzo 1.0. But I must admit, that Rybka 1.0 is stronger.
>
>Chrilly

Thanks for the comments. I finally thought about this issue in more detail and
came up with an even better scheme - at least it's better as far as I can see.

Rather than:

mate score = BIGINT - plies from root

it should be

mate score = BIGINT - 50 move counter value

This gets around the issue of aging mate-value hash entries and allows you to
put your search return value directly into the hash table.

An engine might still prefer capturing something to mating, but whoever isn't
resigning under that circumstance deserves all the punishment he gets there :)

Vas




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.