Changes to gnuchess1.52
Tom Vijlbrief
tom at tnosoes.UUCP
Sat Dec 9 07:29:29 AEST 1989
Original-posting-by: tom at tnosoes.UUCP (Tom Vijlbrief)
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)
Posting-id: 891208.2029
Posting-number: Volume TEST, Number TEST
Archive-name: changes to gnu chess 1.52
[This is an experimental alt.sources re-posting from the
newsgroup(s) gnu.chess.
No attempt has been made to edit, clean, modify, or otherwise
change the contents of the original posting, or to contact the
author. Please consider cross-posting all sources postings to
alt.sources as a matter of course.]
[Comments on this service to emv at math.lsa.umich.edu (Edward Vielmetti)]
I made some changes to gnuchess 1.52:
a) report illegal moves, to avoid hang of sun's chesstool
e2-e5 did not result in: Illegal move
b) add a -a flag (think ahead) which switches easy off, so chesstool can
play with gnuchess thinking in the opponents time:
e.g.: chesstool gnuchessr -a 60 5
The user need no longer hit ^C when easy is off, select(2) is used
to terminate the search.
c) Diagnostics concerning the search are written on stderr. This does not
bother chesstool.
I assume these changes also work for xchess.
===============================================================================
Tom Vijlbrief
TNO Institute for Perception
P.O. Box 23 Phone: +31 34 63 562 11
3769 ZG Soesterberg E-mail: tnosoes!tom at mcvax.cwi.nl
The Netherlands or: uunet!mcvax!tnosoes!tom
===============================================================================
Here are the diffs:
*** gnuchess.c Fri Dec 8 09:43:51 1989
--- org/gnuchess.c Sun Apr 30 17:21:05 1989
***************
*** 291,298 ****
main(argc,argv)
int argc; char *argv[];
{
- int i;
- int ahead= 0;
#ifdef MSDOS
ttable = (struct hashentry huge *)farmalloc(ttblsz *
(unsigned long)sizeof(struct hashentry));
--- 291,296 ----
***************
*** 300,313 ****
ttable = (struct hashentry *)malloc(ttblsz *
(unsigned long)sizeof(struct hashentry));
#endif
- while (argc > 1 && argv[1][0] == '-') {
- switch (argv[1][1]) {
- case 'a': ahead= 1; break;
- default: fprintf(stderr, "Unknown flag\n");
- }
- argv++;
- argc--;
- }
Level = 0; TCflag = false; OperatorTime = 0;
if (argc == 2) Level = atoi(argv[1]);
if (argc == 3)
--- 298,303 ----
***************
*** 316,323 ****
}
Initialize();
NewGame();
- if (ahead)
- seteasy();
while (!(quit))
{
if (bothsides && !mate) SelectMove(opponent,1); else InputCommand();
--- 306,311 ----
***************
*** 349,355 ****
if (iop == 2)
{
UnmakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst);
- /* ShowMessage("Illegal Move!!"); */
return(false);
}
cnt = 0;
--- 337,342 ----
***************
*** 393,399 ****
}
}
if (cnt > 1) ShowMessage("Ambiguous Move!");
- else ShowMessage("Illegal Move!!");
return(false);
}
--- 380,385 ----
No differences encountered
*** nondsp.c Fri Dec 8 11:38:03 1989
--- org/nondsp.c Sun Apr 30 17:24:04 1989
***************
*** 39,45 ****
#include <sys/file.h>
struct tms tmbuf1,tmbuf2;
int TerminateSearch(),Die();
- #include <signal.h>
#endif MSDOS
#include "gnuchess.h"
--- 39,44 ----
***************
*** 51,57 ****
Initialize()
{
- signal(SIGINT,Die); signal(SIGQUIT,Die);
mycnt1 = mycnt2 = 0;
#ifndef MSDOS
#endif
--- 50,55 ----
***************
*** 75,105 ****
Die()
{
char s[80];
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
printz("Abort? ");
scanz("%s",s);
if (strcmp(s,"yes") == 0) ExitChess();
- signal(SIGINT,Die); signal(SIGQUIT,Die);
}
TerminateSearch()
{
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
timeout = true;
bothsides = false;
- signal(SIGINT,Die); signal(SIGQUIT,Die);
}
#endif MSDOS
- seteasy()
- {
- easy = !easy;
- }
- static int ahead;
-
InputCommand()
/*
--- 73,91 ----
***************
*** 128,137 ****
algbr(hint>>8,hint & 0xFF,false);
strcpy(s,mvstr1);
tmp = epsquare;
- fprintf(stderr, "Hint: %s\n", s);
if (VerifyMove(s,1,&mv))
{
- ahead= 1;
SelectMove(computer,2);
VerifyMove(mvstr1,2,&mv);
if (Sdepth > 0) Sdepth--;
--- 114,121 ----
***************
*** 139,148 ****
ft = time((long *)0) - time0;
epsquare = tmp;
}
- ahead= 0;
#ifndef MSDOS
- signal(SIGINT,Die); signal(SIGQUIT,Die);
#endif
while (!(ok || quit))
{
--- 123,130 ----
***************
*** 150,155 ****
--- 132,143 ----
i = scanz("%s",s);
if (i == EOF || s[0] == 0) ExitChess();
player = opponent;
+ ok = VerifyMove(s,0,&mv);
+ if (ok && mv != hint)
+ {
+ Sdepth = 0;
+ ft = 0;
+ }
if (strcmp(s,"bd") == 0)
{
***************
*** 156,180 ****
ClrScreen();
UpdateDisplay(0,0,1,0);
}
! else if (strcmp(s,"alg") == 0) ;
! else if (strcmp(s,"quit") == 0) quit = true;
! else if (strcmp(s,"post") == 0) post = !post;
! else if (strcmp(s,"set") == 0) EditBoard();
! else if (strcmp(s,"go") == 0) ok = true;
! else if (strcmp(s,"help") == 0) help();
! else if (strcmp(s,"force") == 0) force = !force;
! else if (strcmp(s,"book") == 0) Book = NULL;
! else if (strcmp(s,"new") == 0) NewGame();
! else if (strcmp(s,"list") == 0) ListGame();
! else if (strcmp(s,"level") == 0) SelectLevel();
! else if (strcmp(s,"hash") == 0) hashflag = !hashflag;
! else if (strcmp(s,"beep") == 0) beep = !beep;
! else if (strcmp(s,"Awindow") == 0) ChangeAlphaWindow();
! else if (strcmp(s,"Bwindow") == 0) ChangeBetaWindow();
! else if (strcmp(s,"rcptr") == 0) rcptr = !rcptr;
! else if (strcmp(s,"hint") == 0) GiveHint();
! else if (strcmp(s,"zero") == 0) ZeroTTable();
! else if (strcmp(s,"both") == 0)
{
bothsides = !bothsides;
Sdepth = 0;
--- 144,167 ----
ClrScreen();
UpdateDisplay(0,0,1,0);
}
! if (strcmp(s,"quit") == 0) quit = true;
! if (strcmp(s,"post") == 0) post = !post;
! if (strcmp(s,"set") == 0) EditBoard();
! if (strcmp(s,"go") == 0) ok = true;
! if (strcmp(s,"help") == 0) help();
! if (strcmp(s,"force") == 0) force = !force;
! if (strcmp(s,"book") == 0) Book = NULL;
! if (strcmp(s,"new") == 0) NewGame();
! if (strcmp(s,"list") == 0) ListGame();
! if (strcmp(s,"level") == 0) SelectLevel();
! if (strcmp(s,"hash") == 0) hashflag = !hashflag;
! if (strcmp(s,"beep") == 0) beep = !beep;
! if (strcmp(s,"Awindow") == 0) ChangeAlphaWindow();
! if (strcmp(s,"Bwindow") == 0) ChangeBetaWindow();
! if (strcmp(s,"rcptr") == 0) rcptr = !rcptr;
! if (strcmp(s,"hint") == 0) GiveHint();
! if (strcmp(s,"zero") == 0) ZeroTTable();
! if (strcmp(s,"both") == 0)
{
bothsides = !bothsides;
Sdepth = 0;
***************
*** 181,193 ****
SelectMove(opponent,1);
ok = true;
}
! else if (strcmp(s,"reverse") == 0)
{
reverse = !reverse;
ClrScreen();
UpdateDisplay(0,0,1,0);
}
! else if (strcmp(s,"switch") == 0)
{
computer = otherside[computer];
opponent = otherside[opponent];
--- 168,180 ----
SelectMove(opponent,1);
ok = true;
}
! if (strcmp(s,"reverse") == 0)
{
reverse = !reverse;
ClrScreen();
UpdateDisplay(0,0,1,0);
}
! if (strcmp(s,"switch") == 0)
{
computer = otherside[computer];
opponent = otherside[opponent];
***************
*** 195,225 ****
Sdepth = 0;
ok = true;
}
! else if (strcmp(s,"white") == 0 || strcmp(s, "first") == 0)
{
computer = white; opponent = black;
ok = true; force = false;
Sdepth = 0;
}
! else if (strcmp(s,"black") == 0)
{
computer = black; opponent = white;
ok = true; force = false;
Sdepth = 0;
}
! else if (strcmp(s,"undo") == 0 && GameCnt >= 0) Undo();
! else if (strcmp(s,"remove") == 0 && GameCnt >= 1)
{
Undo(); Undo();
}
! else if (strcmp(s,"get") == 0) GetGame();
! else if (strcmp(s,"save") == 0) SaveGame();
! else if (strcmp(s,"depth") == 0) ChangeSearchDepth();
! else if (strcmp(s,"random") == 0) dither = 6;
! else if (strcmp(s,"easy") == 0) seteasy();
! else if (strcmp(s,"contempt") == 0) SetContempt();
! else if (strcmp(s,"xwndw") == 0) ChangeXwindow();
! else if (strcmp(s,"test") == 0)
{
t1 = time(0);
cnt = 0;
--- 182,212 ----
Sdepth = 0;
ok = true;
}
! if (strcmp(s,"white") == 0)
{
computer = white; opponent = black;
ok = true; force = false;
Sdepth = 0;
}
! if (strcmp(s,"black") == 0)
{
computer = black; opponent = white;
ok = true; force = false;
Sdepth = 0;
}
! if (strcmp(s,"undo") == 0 && GameCnt >= 0) Undo();
! if (strcmp(s,"remove") == 0 && GameCnt >= 1)
{
Undo(); Undo();
}
! if (strcmp(s,"get") == 0) GetGame();
! if (strcmp(s,"save") == 0) SaveGame();
! if (strcmp(s,"depth") == 0) ChangeSearchDepth();
! if (strcmp(s,"random") == 0) dither = 6;
! if (strcmp(s,"easy") == 0) easy = !easy;
! if (strcmp(s,"contempt") == 0) SetContempt();
! if (strcmp(s,"xwndw") == 0) ChangeXwindow();
! if (strcmp(s,"test") == 0)
{
t1 = time(0);
cnt = 0;
***************
*** 232,246 ****
rate = cnt / (t2-t1);
printz("cnt= %ld rate= %ld\n",cnt,rate);
}
- else {
- ok = VerifyMove(s,0,&mv);
- if (ok && mv != hint)
- {
- Sdepth = 0;
- ft = 0;
}
- }
- }
ElapsedTime(1);
if (force)
--- 219,225 ----
***************
*** 252,258 ****
#ifdef CHESSTOOL
printf("%d. %s\n",++mycnt2,s);
#endif CHESSTOOL
- signal(SIGINT,TerminateSearch); signal(SIGQUIT,TerminateSearch);
#endif MSDOS
}
--- 231,236 ----
***************
*** 376,391 ****
printz("%5s ",mvstr1);
}
printz("\n");
- #else
- register int i;
- fprintf(stderr,"%2d%c %5d %4ld %7ld ",Sdepth,ch,score,et,NodeCnt);
- for (i = 1; bstline[i] > 0; i++)
- {
- algbr((short)(bstline[i] >> 8),(short)(bstline[i] & 0xFF),false);
- if (i == 9 || i == 17) fprintf(stderr,"\n ");
- fprintf(stderr,"%5s ",mvstr1);
- }
- fprintf(stderr,"\n");
#endif
}
--- 354,359 ----
***************
*** 394,409 ****
short side;
{
#ifndef MSDOS
- signal(SIGINT,TerminateSearch); signal(SIGQUIT,TerminateSearch);
#endif
#ifndef CHESSTOOL
printz("\nMove# %d Target= %ld Clock: %ld\n",
TCmoves-TimeControl.moves[side]+1,
ResponseTime,TimeControl.clock[side]);
- #else
- fprintf(stderr,"\nMove# %d Target= %ld Clock: %ld\n",
- TCmoves-TimeControl.moves[side]+1,
- ResponseTime,TimeControl.clock[side]);
#endif
}
--- 362,372 ----
***************
*** 430,451 ****
ListGame();
exit(0);
}
-
- fprintf(stderr,"Nodes= %ld Eval= %ld Hash= %ld Rate= %ld ",
- NodeCnt,EvalNodes,HashCnt,evrate);
- fprintf(stderr,"CPU= %.2ld:%.2ld.%.2ld\n\n",
- cputimer/6000,(cputimer % 6000)/100,cputimer % 100);
-
- if (root->flags & epmask) UpdateDisplay(0,0,1,0);
- else UpdateDisplay(root->f,root->t,0,root->flags & cstlmask);
- fprintf(stderr,"My move is: %s\n\n",mvstr1);
- /* if (beep) fprintf(stderr,"%c",7); */
-
- if (root->flags & draw) fprintf(stderr,"Draw game!\n");
- else if (root->score == -9999) fprintf(stderr,"opponent mates!\n");
- else if (root->score == 9998) fprintf(stderr,"computer mates!\n");
- else if (root->score < -9000) fprintf(stderr,"opponent will soon mate!\n");
- else if (root->score > 9000) fprintf(stderr,"computer will soon mate!\n");
#else
printz("Nodes= %ld Eval= %ld Hash= %ld Rate= %ld ",
NodeCnt,EvalNodes,HashCnt,evrate);
--- 393,398 ----
***************
*** 465,474 ****
#endif CHESSTOOL
}
- #include <sys/time.h>
- static struct timeval poll;
-
ElapsedTime(iop)
short iop;
--- 412,418 ----
***************
*** 479,489 ****
*/
{
- if (ahead) {
- int in= 1;
- if (select(32, &in, 0, 0, &poll))
- timeout= true;
- }
et = time((long *)0) - time0;
if (et < 0) et = 0;
ETnodes += 50;
--- 423,428 ----
***************
*** 583,589 ****
struct BookEntry *entry;
unsigned short mv,*mp,tmp[100];
! if ((fd = fopen("/usr/local/lib/gnuchess.book","r")) != NULL)
{
/*
setvbuf(fd,buffr,_IOFBF,2048);
--- 522,528 ----
struct BookEntry *entry;
unsigned short mv,*mp,tmp[100];
! if ((fd = fopen("/usr/games/lib/gnuchess.book","r")) != NULL)
{
/*
setvbuf(fd,buffr,_IOFBF,2048);
***************
*** 608,616 ****
i = 0; side = white;
}
fclose(fd);
- } else {
- fprintf(stderr, "No Book!\n");
- exit(1);
}
}
--- 547,552 ----
***************
*** 784,791 ****
{
#ifndef CHESSTOOL
printz("%s\n");
- #else
- printz("%s\n",s);
#endif CHESSTOOL
}
--- 720,725 ----
*** uxdsp.c Fri Dec 8 09:37:23 1989
--- org/uxdsp.c Sun May 7 21:12:53 1989
***************
*** 41,49 ****
#define scanz fflush(stdout),scanw
#define printz printw
- seteasy()
- {
- }
Initialize()
{
--- 41,46 ----
***************
*** 325,331 ****
gotoXY(40,23); printz("Transposition table: ");
if (hashflag) printz("ON"); else printz("OFF");
refresh();
! getchar(); /* while (getchar() != 27); */
ClrScreen();
UpdateDisplay(0,0,1,0);
}
--- 322,328 ----
gotoXY(40,23); printz("Transposition table: ");
if (hashflag) printz("ON"); else printz("OFF");
refresh();
! while (getchar() != 27);
ClrScreen();
UpdateDisplay(0,0,1,0);
}
***************
*** 569,575 ****
struct BookEntry *entry;
unsigned short mv,*mp,tmp[100];
! if ((fd = fopen("/usr/local/lib/gnuchess.book","r")) != NULL)
{
Book = NULL;
i = 0; side = white;
--- 566,572 ----
struct BookEntry *entry;
unsigned short mv,*mp,tmp[100];
! if ((fd = fopen("gnuchess.book","r")) != NULL)
{
Book = NULL;
i = 0; side = white;
***************
*** 591,599 ****
i = 0; side = white;
}
fclose(fd);
- } else {
- fprintf(stderr, "No Book!\n");
- exit(1);
}
}
--- 588,593 ----
No differences encountered
*** Makefile Fri Dec 8 08:47:20 1989
--- org/Makefile Thu Apr 27 04:59:51 1989
***************
*** 37,51 ****
cc -o gnuchessr gnuchess.o nondsp.o
gnuchess.o: gnuchess.c
! cc -O -c gnuchess.c
! #cc -DCHESSTOOL -O -c gnuchess.c
uxdsp.o: uxdsp.c
cc -O -c uxdsp.c
nondsp.o: nondsp.c
! cc -O -c nondsp.c
! #cc -DCHESSTOOL -O -c nondsp.c
distribution:
tar cf - version.h gnuchess.h gnuchess.c uxdsp.c nondsp.c Xchess gnuchess.book DOCUMENTATION Makefile > gnuchess.tar
--- 37,49 ----
cc -o gnuchessr gnuchess.o nondsp.o
gnuchess.o: gnuchess.c
! cc -DCHESSTOOL -O -c gnuchess.c
uxdsp.o: uxdsp.c
cc -O -c uxdsp.c
nondsp.o: nondsp.c
! cc -DCHESSTOOL -O -c nondsp.c
distribution:
tar cf - version.h gnuchess.h gnuchess.c uxdsp.c nondsp.c Xchess gnuchess.book DOCUMENTATION Makefile > gnuchess.tar
***************
*** 52,57 ****
compress gnuchess.tar
install:
! cp gnuchessr /usr/local/gnuchessr
! cp gnuchess /usr/local/gnuchess
! cp gnuchess.book /usr/local/lib/gnuchess.book
--- 50,55 ----
compress gnuchess.tar
install:
! cp gnuchessr /usr/games/gnuchess.chesstool
! cp gnuchess /usr/games/gnuchess
! cp gnuchess.book /usr/games/lib/gnuchess.book
More information about the Alt.sources
mailing list