Crafty bug

Discussion of chess software programming and technical issues.

Moderator: Ras

Cardoso
Posts: 363
Joined: Thu Mar 16, 2006 7:39 pm
Location: Portugal
Full name: Alvaro Cardoso

Crafty bug

Post by Cardoso »

Hi Bob,
I think there is a bug in search.c at line 701.
The first condition (repeat == 2) is allways false, since the only place where that variable can be set to a non zero value or to 2, is at line 75, but then the search returns at line 83. Please fix that, I don't like bugs in crafty :)

best regards,
Alvaro
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty bug

Post by bob »

Cardoso wrote:Hi Bob,
I think there is a bug in search.c at line 701.
The first condition (repeat == 2) is allways false, since the only place where that variable can be set to a non zero value or to 2, is at line 75, but then the search returns at line 83. Please fix that, I don't like bugs in crafty :)

best regards,
Alvaro
Thanks. In all the cleaning up, something was lost. The key here is that if RepetitionCheck() returns a 2, that signals a 50 move draw. But I don't want to force the score to zero at the top of search, I want to first search to see if I am mated at this ply, which requires going through a search first. I'm supposed to defer the repeat==2 draw until I verify I can't mate my opponent instead. But that seems to have gotten lost somewhere along the way...

Will be fixed in next version...
Last edited by bob on Thu Jun 26, 2014 9:14 pm, edited 1 time in total.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty bug

Post by bob »

bob wrote:
Cardoso wrote:Hi Bob,
I think there is a bug in search.c at line 701.
The first condition (repeat == 2) is allways false, since the only place where that variable can be set to a non zero value or to 2, is at line 75, but then the search returns at line 83. Please fix that, I don't like bugs in crafty :)

best regards,
Alvaro
Thanks. In all the cleaning up, something was lost. The key here is that if RepetitionCheck() returns a 2, that signals a 50 move draw. But I don't want to force the score to zero at the top of search, I want to first search to see if I am mated, which needs to run through search to find a legal move. I'm supposed to defer the repeat==2 draw until I verify I can't mate my opponent instead. But that seems to have gotten lost somewhere along the way...

Will be fixed in next version...
If you want to fix it in 24.0, change the block of code that calls RepetitionCheck() back to what it was in 23.x versions:

Code: Select all

if ((repeat = Repeat(tree, ply))) {
      if (repeat == 1 || !tree->inchk[ply]) {
        value = DrawScore(wtm);
        if (value < beta)
          SavePV(tree, ply, 0);
#if defined(TRACE)
        if (ply <= trace_level)
          printf("draw by repetition detected, ply=%d.\n", ply);
#endif
        return value;
      }
    }
JVMerlino
Posts: 1407
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Crafty bug

Post by JVMerlino »

bob wrote:
Cardoso wrote:Hi Bob,
I think there is a bug in search.c at line 701.
The first condition (repeat == 2) is allways false, since the only place where that variable can be set to a non zero value or to 2, is at line 75, but then the search returns at line 83. Please fix that, I don't like bugs in crafty :)

best regards,
Alvaro
Thanks. In all the cleaning up, something was lost. The key here is that if RepetitionCheck() returns a 2, that signals a 50 move draw. But I don't want to force the score to zero at the top of search, I want to first search to see if I am mated at this ply, which requires going through a search first. I'm supposed to defer the repeat==2 draw until I verify I can't mate my opponent instead. But that seems to have gotten lost somewhere along the way...

Will be fixed in next version...
Heh, I had that same bug in Myrddin. "Hooray, I made it to a 50-move draw! Wait, what do you mean, checkmate...?"

jm