[gnu.chess] gnuchess bad movement

rosa@maui.cs.ucla.edu (Berthier Ribeiro Araujo Neto) (09/26/89)

I got some problems with gnuchess. It is running, but plays strangely
sometimes. In the game below, it moves the pawn over the knight when 
I play  
	
	f1e1 (rook one square left).
	
Could anyone try this movement to see it the mistake happens in other 
environments?


Thank you in advance,

	--Berthier



>>>>>>>> the game >>>>>>>>>>>>>.


2 1 17
1 1 0 0
1 0
223 1485 52 52
1025
0
0
1281
0
1025
1537
0
257
257
257
769
0
257
257
257
0
0
513
769
257
513
0
0
0
770
0
257
0
0
0
0
0
0
0
258
0
0
0
0
258
0
514
0
258
514
0
0
0
258
258
770
0
258
258
258
1026
0
0
1282
0
1026
1538
0
2843 0 0 0 19 0 0
13091 0 0 0 0 0 0
1557 0 0 0 12 0 0
15917 0 0 0 0 0 0
274 0 0 0 213 0 0
13356 -3 4 7861 37 0 0
541 0 0 0 50 0 0
15641 38 4 8134 29 0 0
7435 0 0 0 82 0 0
14634 27 4 11393 43 0 0
3092 0 0 0 405 0 0
12328 3 4 10125 43 0 0
1299 0 0 0 149 0 0
15422 -2 4 11418 41 0 2
1030 0 0 0 103 0 1
14899 -8 4 9029 41 0 0

dpi@loft386.UUCP (Doug Ingraham) (09/27/89)

In article <27401@shemp.CS.UCLA.EDU>, rosa@maui.cs.ucla.edu (Berthier Ribeiro Araujo Neto) writes:
> I got some problems with gnuchess. It is running, but plays strangely
> sometimes. In the game below, it moves the pawn over the knight when 
> I play  
> 	
> 	f1e1 (rook one square left).
> 	
> Could anyone try this movement to see it the mistake happens in other 
> environments?
> 
> 
> Thank you in advance,
> 
> 	--Berthier

The problem is in the new module move.c in the function GenMoves.  Here in
its entirety is GenMoves with the blocked double pawn advance fixed and
the missing test for enpassant pawn captures.

--------------------------------- cut here ---------------------------------
#if (NEWMOVE > 5)
GenMoves(ply,sq,side,xside)
     short ply,sq,side,xside;

/*
  Generate moves for a piece. The moves are taken from the
  precalulated array posdata. If the board is free, next move
  is choosen from nextpos else from nextdir.
*/

{
  register short u,piece;
  register struct sqdata *p;

  piece = board[sq];
  p = posdata[side][piece][sq];
  if (piece == pawn) {
    u = p[sq].nextdir; /* follow captures thread */
    while (u != sq) {
      if (color[u] == xside || u == epsquare) LinkMove(ply,sq,u,xside);
      u = p[u].nextdir;
    }
    u = p[sq].nextpos; /* and follow no captures thread */
    while (u != sq) {
      if (color[u] == neutral) {
        LinkMove(ply,sq,u,xside);
        u = p[u].nextpos;
      } else break;	/* this will prevent a double move if blocked */
    }
  }
  else {
    u = p[sq].nextpos;
    while (u != sq) {
      if (color[u] == neutral) {
	LinkMove(ply,sq,u,xside);
	u = p[u].nextpos;
      }
      else {
	if (color[u] == xside) LinkMove(ply,sq,u,xside);
	u = p[u].nextdir;
      }
    }
  }
}
#endif
--------------------------------- cut again ----------------------------

I haven't found any other real bugs, but changing several for loops
to memset and memcpy made a 30% difference in speed.  I also changed
an if then else sequence to a switch which speeded it up 5%.  I cleaned
up the board editor code.  Also some trivial name changes for compatibility
with SYSTEM V 3.2 curses.  The variable beep conflicts with a curses
beep function.

I will be sending diffs to Stuart Cracraft for inclusion in the next
release.

I hope this helps.

-- 
Doug Ingraham (SysAdmin)
Lofty Pursuits (Public Access for Rapid City SD USA)
uunet!loft386!dpi

scott@s.cs.uiuc.edu (09/27/89)

>[report of an illegal move by gnuchess]

That's because the new move generator in gnuchess 1.53 is buggy.
It's faster than the old one, but it doesn't understand that
a blocked pawn can't move two squares. It also doesn't know about
en passant captures. I'm told the author has been notified.

I suggest sticking to the previous release for now, gnuchess 1.52.

	Jay Scott
	scott@cs.uiuc.edu

hes@baso.nmpcad.se (Hans-Erik Sandstrom LOG/SV) (09/28/89)

In article <231300001@s.cs.uiuc.edu> scott@s.cs.uiuc.edu writes:
>
>
>>[report of an illegal move by gnuchess]
>
>That's because the new move generator in gnuchess 1.53 is buggy.
>It's faster than the old one, but it doesn't understand that
>a blocked pawn can't move two squares. It also doesn't know about
>en passant captures. I'm told the author has been notified.
>
>I suggest sticking to the previous release for now, gnuchess 1.52.
>
>	Jay Scott
>	scott@cs.uiuc.edu


Dont bother to fix this bug in gnuchess 1.53 it has been fixed months ago.

I was`nt aware that this version of gnuchess had been released, It is
a somewhat premature version. The version I had intended for release was
posted to fsf 27 june. I wonder why this version has not been released
yet. There is actually an even newer version with some very rare
(probably newer encountered) bugs in version 1.52 corrected.

memcpy can be an improvement in some places but this depends on the
machine you are using so thats why they are commented out in the 
official release of gnuchess.

I would really like some feedback on the new move generator.
Send this to my address below.
Hans Eric Sandstr|m                     E-mail: hes@log-sv.se
Base/OPEN development                           ...!mcvax!enea!log-sv!hes
TeleLOGIC Sundsvall AB
Box 883                                 Tel:    +46 60 161098