Page 1 of 1

Winboard bug?

PostPosted: 25 Apr 2009, 18:34
by Miguel A. Ballicora
In this position

http://webchess.freehostia.com/diag/che ... or3=000000

The game was adjudicated draw by xboard with this message:
Black wins on time but bare king

Miguel
PS: How do I insert the diagram that I show above in the post?

Re: Winboard bug?

PostPosted: 27 Apr 2009, 16:26
by H.G.Muller
Well, it sure looks like a bug, if you are absolutely certain that the ruling referred to this digram. I cannot spot an error in the code, though:

Code: Select all
       /* [HGM] bare: don't allow bare King to win */
       if((gameInfo.holdingsWidth == 0 || gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat)
          && result != GameIsDrawn)
       {   int i, j, k=0, color = (result==WhiteWins ? (int)WhitePawn : (int)BlackPawn);
      for(j=BOARD_LEFT; j<BOARD_RGHT; j++) for(i=0; i<BOARD_HEIGHT; i++) {
         int p = (int)boards[forwardMostMove][i][j] - color;
         if(p >= 0 && p <= (int)WhiteKing) k++;
      }
      if (appData.debugMode) {
            fprintf(debugFP, "GE(%d, %s, %d) bare king k=%d color=%d\n",
          result, resultDetails ? resultDetails : "(null)", whosays, k, color);
      }
      if(k <= 1) {
         result = GameIsDrawn;
         sprintf(buf, "%s but bare king", resultDetails);
         resultDetails = buf;
      }
       }

I simply count the number of pieces of the winning side that is between Pawn and King (which should be all pieces), and if it is one, it must be a bare King. Perhaps I am counting on the wrong board here. I guess the clock interrupt causing the forfit ust have come between incrementing the move number and pressing the clock for that move, before the board was fully copied.

Indeed, the MakeMove() routine starts incrementing forwardMostMove, then does SwitchClock(), and only then copies the board. Between forwardMostMove++; and SwitchClocks(); there are only two if() statements, both with false conditions in your case. (One testing if there are more than 500 moves, making the game history overflow, the other a hack for broadcasting the game with my ChessLive! viewer.) So there must be only an extremely short time between them.

But to be absolutely safe I should put the forwardMostMov++; behind updating the board. Yegh. That means I have to replace it by forwardMostMove+1 everywhere in between. And it is used quite often...

Re: Winboard bug?

PostPosted: 27 Apr 2009, 17:41
by webchess
Miguel A. Ballicora wrote:PS: How do I insert the diagram that I show above in the post?


Please read FAQ

Image

Re: Winboard bug?

PostPosted: 27 Apr 2009, 17:46
by Volker Pittlik
Miguel A. Ballicora wrote:...
PS: How do I insert the diagram that I show above in the post?



http://www.open-aurec.com/wbforum/viewtopic.php?f=22&t=49351

Re: Winboard bug?

PostPosted: 28 Apr 2009, 02:22
by Miguel A. Ballicora
Volker Pittlik wrote:
Miguel A. Ballicora wrote:...
PS: How do I insert the diagram that I show above in the post?



http://www.open-aurec.com/wbforum/viewtopic.php?f=22&t=49351


Thanks to both messages,

I read that, and that is how I learned how to build the board. However, It does not say how to insert the image. I think it would be a good idea to complete the howto with this information. In the FAQ says that [img] needs to be used. I actually tried it but I must have done something wrong. Since the howto did not say anything, I gave up too soon.

Miguel

Re: Winboard bug?

PostPosted: 28 Apr 2009, 16:10
by F. Bluemers
If you quote a message containing a diagram , you can see how its done.