Article View: gnu.chess
Article #5874Gnuchess openning book verification routine
From: Daryl K. Baker
Date: Sat, 04 Jan 1992 14:43
Date: Sat, 04 Jan 1992 14:43
85 lines
2942 bytes
2942 bytes
While playing around with porting gnuchess I kept running into problems
with the program dropping out of the opening book. I modified the input
routine to verify the opening book. It is a little crude, but could be
helpful to others if they add moves to the opening book. (The original
book had numerous illegal moves).
Daryl Baker
dkb@mitre.org
======
Add to nondsp.c
#ifdef DEBUGBOOK
void
InputCommand (void)
{
#ifndef BOOK
#define BOOK "/usr/games/lib/gnuchess.book"
#endif /* BOOK */
FILE *fd;
int c, i, j, side, ok;
int line;
short unsigned int mv;
int startnewline;
char s[80];
char buff[2048], *buffr;
char blk[12], wht[12];
printz ("Verifying openning book\n");
if ((fd = fopen (BOOK, "r")) == NULL) fd = fopen ("gnuchess.book", "r");
if (fd != NULL) {
line = 0;
startnewline = false;
while ( fgets ( buff, sizeof (buff),fd ) != NULL ) {
buffr = buff;
line ++;
while ( isalpha(*buffr) && isspace(*buffr) && *buffr) buffr ++;
if ( *buffr == '!') {
if ( startnewline ) {
NewGame();
}
startnewline = false;
continue;
}
*wht = '\0'; *blk='\0';
sscanf ( buffr, "%10s %10s", &wht, &blk);
startnewline = true;
/* verify the white move */
if ( *wht ) {
computer = black;
opponent = white;
player = opponent;
Sdepth = 0;
ok = VerifyMove (wht, 0, &mv);
if ( !ok ) {
printz ("\nbad white move %s on line %d\n",wht, line);
break;
}
}
/* verify the black move */
if ( *blk ) {
computer = white;
opponent = black;
player = opponent;
Sdepth = 0;
ok = VerifyMove (blk, 0, &mv);
if ( !ok ) {
printz ("\nbad black move %s on line %d\n",blk, line);
break;
}
}
}
fclose (fd);
} else printz ("can't find book\n");
flag.quit = true;
}
#else
/* The regular InputCommand routine goes here */
#endif
Technical Details
Message-ID:
<1992Jan4.144330.4680@linus.mitre.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!agate!linus!linus!bistromath!dkbReferences:
<9201021534.AA23795@rice-chex>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d71d,961f5581d4cd6f44,start X-Google-Attributes: gid10d71d,public X-Google-ArrivalTime: 1992-01-04 07:25:04 PST Newsgroups: gnu.chess Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!agate!linus!linus!bistromath!dkb From: dkb@bistromath.mitre.org (Daryl K. Baker) Subject: Gnuchess openning book verification routine Message-ID: <1992Jan4.144330.4680@linus.mitre.org> Summary: Alternate input routine to verify moves in opening book Keywords: Gnuchess opening book Sender: news@linus.mitre.org (News Service) Nntp-Posting-Host: bistromath.mitre.org Organization: The MITRE Corporation, Bedford, MA References: <9201021534.AA23795@rice-chex> Distribution: gnu Date: Sat, 4 Jan 1992 14:43:30 GMT Lines: 85