[comp.sources.games] v04i060: gnuchess2 - latest version of the GNU Chess program, Patch1

games@tekred.TEK.COM (06/22/88)

Submitted by: libove@cs.cmu.edu (Jay Libove)
Comp.sources.games: Volume 4, Issue 60
Archive-name: gnuchess2/Patch1


[[Here is a set of patches that will make the recently posted GNU Chess
version 2 run under SCO Xenix SysV/286 with the development system
revision 2.1.4g. Presumably, this will work also for any SCO system
newer than the above mentioned, and might work for older ones.
Simply unshar the files below to produce gnuchess.c.dif, gnuchess.h.dif,
uxdsp.c.dif, and Makefile.xnx. Cat together the distribution files
gnuchess.c1 and gnuchess.c2 in to gnuchess.c and patch from gnuchess.c.dif,
and patch from gnuchess.h.dif and uxdsp.c.dif. Copy Makefile.xnx to
Makefile and do a make. (Or do a make -f Makefile.xnx, whatever).

Any problems, please do mail to me and I'll do my best!
-- 
Jay Libove               Internet: libove@cs.cmu.edu libove@andrew.cmu.edu
5313 Ellsworth Avenue              formtek!ditka!libove!libove@pt.cs.cmu.edu
Pittsburgh, PA 15232         UUCP: cmucspt!formtek!ditka!libove!libove
(412) 621-9649                     cadre!pitt!darth!libove!libove
]]

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  gnuchess.c.dif
#	  gnuchess.h.dif
#	  uxdsp.c.dif
#	  Makefile.xnx
#
if test -f gnuchess.c.dif; then echo "File gnuchess.c.dif exists"; else
echo "x - extracting gnuchess.c.dif (Text)"
sed 's/^X//' << 'SHAR_EOF' > gnuchess.c.dif &&
X*** ../gnuchess.c.dst	Tue Jun 21 03:27:57 1988
X--- gnuchess.c	Tue Jun 21 02:14:22 1988
X***************
X*** 34,39
X  #include <alloc.h>
X  #define ttblsz 4096
X  #else
X  #include <sys/param.h>
X  #include <sys/times.h>
X  #define ttblsz 16384
X
X--- 34,43 -----
X  #include <alloc.h>
X  #define ttblsz 4096
X  #else
X+ #ifdef M_XENIX
X+ # include <sys/types.h>
X+   extern char *malloc();
X+ #endif /* M_XENIX */
X  #include <sys/param.h>
X  #include <sys/times.h>
X  #define ttblsz 16384
X***************
X*** 689,694
X  short xside,pbst,d,e,cf,score,rcnt;
X  unsigned short mv,nxtline[maxdepth];
X  struct leaf *node,tmp;
X  
X    NodeCnt++;
X    xside = otherside[side];
X
X--- 693,701 -----
X  short xside,pbst,d,e,cf,score,rcnt;
X  unsigned short mv,nxtline[maxdepth];
X  struct leaf *node,tmp;
X+ #ifdef M_XENIX
X+ struct leaf xnxtmp;
X+ #endif /* M_XENIX */
X  
X    NodeCnt++;
X    xside = otherside[side];
X***************
X*** 780,785
X                if (best == alpha)
X                  {
X                    tmp = Tree[pnt];
X                    for (j = pnt-1; j >= 0; j--) Tree[j+1] = Tree[j];
X                    Tree[0] = tmp;
X                    pbst = 0;
X
X--- 787,793 -----
X                if (best == alpha)
X                  {
X                    tmp = Tree[pnt];
X+ #ifndef M_XENIX
X                    for (j = pnt-1; j >= 0; j--) Tree[j+1] = Tree[j];
X  #else /* M_XENIX */
X                    for (j=(pnt-1);j>=0;j--) {xnxtmp=Tree[j];Tree[j+1]=xnxtmp;};
X***************
X*** 781,786
X                  {
X                    tmp = Tree[pnt];
X                    for (j = pnt-1; j >= 0; j--) Tree[j+1] = Tree[j];
X                    Tree[0] = tmp;
X                    pbst = 0;
X                  }
X
X--- 789,797 -----
X                    tmp = Tree[pnt];
X  #ifndef M_XENIX
X                    for (j = pnt-1; j >= 0; j--) Tree[j+1] = Tree[j];
X+ #else /* M_XENIX */
X+                   for (j=(pnt-1);j>=0;j--) {xnxtmp=Tree[j];Tree[j+1]=xnxtmp;};
X+ #endif /* M_XENIX */
X                    Tree[0] = tmp;
X                    pbst = 0;
X                  }
X***************
X*** 1481,1486
X  {
X  register short p,s,p0,s0;
X  struct leaf temp;
X  
X    s0 = Tree[p1].score; p0 = p1;
X    for (p = p1+1; p <= p2; p++)
X
X--- 1492,1500 -----
X  {
X  register short p,s,p0,s0;
X  struct leaf temp;
X+ #ifdef M_XENIX
X+ struct leaf xnxtmp;
X+ #endif /* M_XENIX */
X  
X    s0 = Tree[p1].score; p0 = p1;
X    for (p = p1+1; p <= p2; p++)
X***************
X*** 1490,1495
X        }
X    if (p0 != p1)
X      {
X        temp = Tree[p1]; Tree[p1] = Tree[p0]; Tree[p0] = temp;
X      }
X  }
X
X--- 1504,1510 -----
X        }
X    if (p0 != p1)
X      {
X+ #ifndef M_XENIX
X        temp = Tree[p1]; Tree[p1] = Tree[p0]; Tree[p0] = temp;
X  #else /* M_XENIX */
X        temp = Tree[p1];
X***************
X*** 1491,1496
X    if (p0 != p1)
X      {
X        temp = Tree[p1]; Tree[p1] = Tree[p0]; Tree[p0] = temp;
X      }
X  }
X  
X
X--- 1506,1517 -----
X      {
X  #ifndef M_XENIX
X        temp = Tree[p1]; Tree[p1] = Tree[p0]; Tree[p0] = temp;
X+ #else /* M_XENIX */
X+       temp = Tree[p1];
X+       xnxtmp = Tree[p0];
X+       Tree[p1] = xnxtmp;
X+       Tree[p0] = temp;
X+ #endif /* M_XENIX */
X      }
X  }
X  
X***************
X*** 1621,1627
X  {
X  register short sq,s,i,xside;
X  short pscore[3];
X! 
X    wking = PieceList[white][0]; bking = PieceList[black][0];
X    UpdateWeights();
X    xside = otherside[side];
X
X--- 1642,1650 -----
X  {
X  register short sq,s,i,xside;
X  short pscore[3];
X! #ifdef M_XENIX
X! short *xnxtmp;
X! #endif /* M_XENIX */
X    wking = PieceList[white][0]; bking = PieceList[black][0];
X    UpdateWeights();
X    xside = otherside[side];
X***************
X*** 1631,1636
X      {
X        c2 = otherside[c1];
X        if (c1 == white) EnemyKing = bking; else EnemyKing = wking;
X        atk1 = atak[c1]; atk2 = atak[c2];
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        for (i = 0; i <= PieceCnt[c1]; i++)
X
X--- 1654,1660 -----
X      {
X        c2 = otherside[c1];
X        if (c1 == white) EnemyKing = bking; else EnemyKing = wking;
X+ #ifndef M_XENIX
X        atk1 = atak[c1]; atk2 = atak[c2];
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X  #else /* M_XENIX */
X***************
X*** 1633,1638
X        if (c1 == white) EnemyKing = bking; else EnemyKing = wking;
X        atk1 = atak[c1]; atk2 = atak[c2];
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        for (i = 0; i <= PieceCnt[c1]; i++)
X          {
X            sq = PieceList[c1][i];
X
X--- 1657,1672 -----
X  #ifndef M_XENIX
X        atk1 = atak[c1]; atk2 = atak[c2];
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X+ #else /* M_XENIX */
X+       xnxtmp = atak[c1];
X+       atk1 = xnxtmp;
X+       xnxtmp = atak[c2];
X+       atk2 = xnxtmp;
X+       xnxtmp = PawnCnt[c1];
X+       PC1 = xnxtmp;
X+       xnxtmp = PawnCnt[c2];
X+       PC2 = xnxtmp;
X+ #endif /* M_XENIX */
X        for (i = 0; i <= PieceCnt[c1]; i++)
X          {
X            sq = PieceList[c1][i];
SHAR_EOF
chmod 0644 gnuchess.c.dif || echo "restore of gnuchess.c.dif fails"
set `wc -c gnuchess.c.dif`;Sum=$1
if test "$Sum" != "4827"
then echo original size 4827, current size $Sum;fi
fi
if test -f gnuchess.h.dif; then echo "File gnuchess.h.dif exists"; else
echo "x - extracting gnuchess.h.dif (Text)"
sed 's/^X//' << 'SHAR_EOF' > gnuchess.h.dif &&
X*** ../gnuchess.h.dst	Tue Jun 21 03:50:08 1988
X--- gnuchess.h	Tue Jun 21 01:48:22 1988
X***************
X*** 20,25
X    and this notice must be preserved on all copies.
X  */
X  
X  
X  /* Header file for GNU CHESS */  
X  
X
X--- 20,32 -----
X    and this notice must be preserved on all copies.
X  */
X  
X+ /* the gnuchess.book file's location */
X+ 
X+ static char *gcbook = "/usr/games/lib/gnuchess.book";
X+ 
X+ /* to avoid compiler assumption that malloc() returns int */
X+ 
X+ extern char *malloc();
X  
X  /* Header file for GNU CHESS */  
X  
SHAR_EOF
chmod 0644 gnuchess.h.dif || echo "restore of gnuchess.h.dif fails"
set `wc -c gnuchess.h.dif`;Sum=$1
if test "$Sum" != "531"
then echo original size 531, current size $Sum;fi
fi
if test -f uxdsp.c.dif; then echo "File uxdsp.c.dif exists"; else
echo "x - extracting uxdsp.c.dif (Text)"
sed 's/^X//' << 'SHAR_EOF' > uxdsp.c.dif &&
X*** ../uxdsp.c.dst	Tue Jun 21 03:45:26 1988
X--- uxdsp.c	Tue Jun 21 03:26:31 1988
X***************
X*** 30,35
X  
X  #include <stdio.h>
X  #include <ctype.h>
X  #include <sys/param.h>
X  #include <sys/times.h>
X  #include <sys/file.h>
X
X--- 30,39 -----
X  
X  #include <stdio.h>
X  #include <ctype.h>
X+ #ifdef M_XENIX
X+ # include <curses.h>
X+ # include <sys/types.h>
X+ #endif /* M_XENIX */
X  #include <sys/param.h>
X  #include <sys/times.h>
X  #include <sys/file.h>
X***************
X*** 33,38
X  #include <sys/param.h>
X  #include <sys/times.h>
X  #include <sys/file.h>
X  #include <curses.h>
X  #include <signal.h>
X  #include "gnuchess.h"
X
X--- 37,43 -----
X  #include <sys/param.h>
X  #include <sys/times.h>
X  #include <sys/file.h>
X+ #ifndef M_XENIX
X  #include <curses.h>
X  #endif /* M_XENIX */
X  #include <signal.h>
X***************
X*** 34,39
X  #include <sys/times.h>
X  #include <sys/file.h>
X  #include <curses.h>
X  #include <signal.h>
X  #include "gnuchess.h"
X  
X
X--- 39,45 -----
X  #include <sys/file.h>
X  #ifndef M_XENIX
X  #include <curses.h>
X+ #endif /* M_XENIX */
X  #include <signal.h>
X  #include "gnuchess.h"
X  
X***************
X*** 42,47
X  
X  #define scanz fflush(stdout),scanw
X  #define printz printw
X  
X  
X  Initialize()
X
X--- 48,56 -----
X  
X  #define scanz fflush(stdout),scanw
X  #define printz printw
X+ #ifdef M_XENIX
X+ # define W_OK 2
X+ #endif /* M_XENIX */
X  
X  Initialize()
X  {
X***************
X*** 43,49
X  #define scanz fflush(stdout),scanw
X  #define printz printw
X  
X- 
X  Initialize()
X  {
X    signal(SIGINT,Die); signal(SIGQUIT,Die);
X
X--- 52,57 -----
X  # define W_OK 2
X  #endif /* M_XENIX */
X  
X  Initialize()
X  {
X    signal(SIGINT,Die); signal(SIGQUIT,Die);
X***************
X*** 571,577
X  struct BookEntry *entry;
X  unsigned short mv,*mp,tmp[100];
X  
X!   if ((fd = fopen("gnuchess.book","r")) != NULL)
X      {
X        Book = NULL;
X        i = 0; side = white;
X
X--- 579,585 -----
X  struct BookEntry *entry;
X  unsigned short mv,*mp,tmp[100];
X  
X!   if ((fd = fopen(gcbook,"r")) != NULL)
X      {
X        Book = NULL;
X        i = 0; side = white;
X***************
X*** 609,615
X    while (c != ' ' && c != '\n' && c != EOF) s[++i] = c = getc(fd);
X    s[++i] = '\0';
X    if (c == EOF) return(-1);
X!   if (s[0] == '!' || i < 3)
X      {
X        while (c != '\n' && c != EOF) c = getc(fd);
X        return(0);
X
X--- 617,623 -----
X    while (c != ' ' && c != '\n' && c != EOF) s[++i] = c = getc(fd);
X    s[++i] = '\0';
X    if (c == EOF) return(-1);
X!   if ((s[0] == '!') || (i < 3))
X      {
X        while ((c != '\n') && (c != EOF)) c = getc(fd);
X        return(0);
X***************
X*** 611,617
X    if (c == EOF) return(-1);
X    if (s[0] == '!' || i < 3)
X      {
X!       while (c != '\n' && c != EOF) c = getc(fd);
X        return(0);
X      }
X    if (s[4] == 'o')
X
X--- 619,625 -----
X    if (c == EOF) return(-1);
X    if ((s[0] == '!') || (i < 3))
X      {
X!       while ((c != '\n') && (c != EOF)) c = getc(fd);
X        return(0);
X      }
X    if (s[4] == 'o')
X***************
X*** 615,620
X        return(0);
X      }
X    if (s[4] == 'o')
X      if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
X    else if (s[0] == 'o')
X      if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
X
X--- 623,629 -----
X        return(0);
X      }
X    if (s[4] == 'o')
X+     {
X      if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
X      }
X    else if (s[0] == 'o')
X***************
X*** 616,621
X      }
X    if (s[4] == 'o')
X      if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
X    else if (s[0] == 'o')
X      if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
X    else
X
X--- 625,631 -----
X    if (s[4] == 'o')
X      {
X      if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
X+     }
X    else if (s[0] == 'o')
X      {
X      if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
X***************
X*** 617,622
X    if (s[4] == 'o')
X      if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
X    else if (s[0] == 'o')
X      if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
X    else
X      {
X
X--- 627,633 -----
X      if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
X      }
X    else if (s[0] == 'o')
X+     {
X      if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
X      }
X    else
X***************
X*** 618,623
X      if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
X    else if (s[0] == 'o')
X      if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
X    else
X      {
X        c1 = s[0] - 'a'; r1 = s[1] - '1';
X
X--- 629,635 -----
X    else if (s[0] == 'o')
X      {
X      if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
X+     }
X    else
X      {
X        c1 = s[0] - 'a'; r1 = s[1] - '1';
X***************
X*** 877,882
X  ShowPostnValues()
X  {
X  short i,r,c;
X    ExaminePosition();
X    for (i = 0; i < 64; i++)
X      {
X
X--- 889,897 -----
X  ShowPostnValues()
X  {
X  short i,r,c;
X+ #ifdef M_XENIX
X+ short *xnxtmp;
X+ #endif /* M_XENIX */
X    ExaminePosition();
X    for (i = 0; i < 64; i++)
X      {
X***************
X*** 884,889
X        if (reverse) c = 7-column[i]; else c = column[i];
X        gotoXY(4+5*c,5+2*(7-r));
X        c1 = color[i]; c2 = otherside[c1];
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        atk1 = atak[c1]; atk2 = atak[c2];
X        if (color[i] == neutral) printz("   ");
X
X--- 899,905 -----
X        if (reverse) c = 7-column[i]; else c = column[i];
X        gotoXY(4+5*c,5+2*(7-r));
X        c1 = color[i]; c2 = otherside[c1];
X+ #ifndef M_XENIX
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        atk1 = atak[c1]; atk2 = atak[c2];
X  #else /* M_XENIX */
X***************
X*** 886,891
X        c1 = color[i]; c2 = otherside[c1];
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        atk1 = atak[c1]; atk2 = atak[c2];
X        if (color[i] == neutral) printz("   ");
X        else printz("%3d ",SqValue(i,opponent));
X      }
X
X--- 902,917 -----
X  #ifndef M_XENIX
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        atk1 = atak[c1]; atk2 = atak[c2];
X+ #else /* M_XENIX */
X+       xnxtmp = PawnCnt[c1];
X+       PC1 = xnxtmp;
X+       xnxtmp = PawnCnt[c2];
X+       PC2 = xnxtmp;
X+       xnxtmp = atak[c1];
X+       atk1 = xnxtmp;
X+       xnxtmp = atak[c2];
X+       atk2 = xnxtmp;
X+ #endif /* M_XENIX */
X        if (color[i] == neutral) printz("   ");
X        else printz("%3d ",SqValue(i,opponent));
X      }
X***************
X*** 899,904
X  {
X  short k,p,i,r,c,tp,tc;
X  char s[40];
X    ExaminePosition();
X    ShowMessage("Enter piece: ");
X    scanz("%s",s);
X
X--- 925,933 -----
X  {
X  short k,p,i,r,c,tp,tc;
X  char s[40];
X+ #ifdef M_XENIX
X+ short *xnxtmp;
X+ #endif /* M_XENIX */
X    ExaminePosition();
X    ShowMessage("Enter piece: ");
X    scanz("%s",s);
X***************
X*** 918,923
X        tp = board[i]; tc = color[i];
X        board[i] = p; color[i] = k;
X        c1 = k; c2 = otherside[c1];
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        atk1 = atak[c1]; atk2 = atak[c2];
X        printz("%3d ",SqValue(i,opponent));
X
X--- 947,953 -----
X        tp = board[i]; tc = color[i];
X        board[i] = p; color[i] = k;
X        c1 = k; c2 = otherside[c1];
X+ #ifndef M_XENIX
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        atk1 = atak[c1]; atk2 = atak[c2];
X  #else /* M_XENIX */
X***************
X*** 920,925
X        c1 = k; c2 = otherside[c1];
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        atk1 = atak[c1]; atk2 = atak[c2];
X        printz("%3d ",SqValue(i,opponent));
X        board[i] = tp; color[i] = tc;
X      }
X
X--- 950,965 -----
X  #ifndef M_XENIX
X        PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
X        atk1 = atak[c1]; atk2 = atak[c2];
X+ #else /* M_XENIX */
X+       xnxtmp = PawnCnt[c1];
X+       PC1 = xnxtmp;
X+       xnxtmp = PawnCnt[c2];
X+       PC2 = xnxtmp;
X+       xnxtmp = atak[c1];
X+       atk1 = xnxtmp;
X+       xnxtmp = atak[c2];
X+       atk2 = xnxtmp;
X+ #endif /* M_XENIX */
X        printz("%3d ",SqValue(i,opponent));
X        board[i] = tp; color[i] = tc;
X      }
SHAR_EOF
chmod 0644 uxdsp.c.dif || echo "restore of uxdsp.c.dif fails"
set `wc -c uxdsp.c.dif`;Sum=$1
if test "$Sum" != "7739"
then echo original size 7739, current size $Sum;fi
fi
if test -f Makefile.xnx; then echo "File Makefile.xnx exists"; else
echo "x - extracting Makefile.xnx (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile.xnx &&
X#
X# Makefile for CHESS
X#
X# Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
X#
X# This file is part of CHESS.
X#
X# CHESS is distributed in the hope that it will be useful,
X# but WITHOUT ANY WARRANTY.  No author or distributor
X# accepts responsibility to anyone for the consequences of using it
X# or for whether it serves any particular purpose or works at all,
X# unless he says so in writing.  Refer to the CHESS General Public
X# License for full details.
X#
X# Everyone is granted permission to copy, modify and redistribute
X# CHESS, but only under the conditions described in the
X# CHESS General Public License.   A copy of this license is
X# supposed to have been given to you along with CHESS so you
X# can know your rights and responsibilities.  It should be in a
X# file named COPYING.  Among other things, the copyright notice
X# and this notice must be preserved on all copies.
X#
X#
X# gnuchess is the alpha-display version
X# nchess   is the CHESSTOOL version
X#
X#
X
Xall : gnuchess # nchess
X
Xgnuchess: gnuchess.o uxdsp.o
X	cc -Ml2e -o gnuchess gnuchess.o uxdsp.o -lcurses -ltermlib
X
Xnchess: gnuchess.o nondsp.o
X	cc -o nchess gnuchess.o nondsp.o
X
Xgnuchess.o: gnuchess.c
X	cc -Ml2e -LARGE -c gnuchess.c
X
Xuxdsp.o: uxdsp.c
X	cc -Ml2e -LARGE -c uxdsp.c
X
Xnondsp.o: nondsp.c
X	cc -O -DCHESSTOOL -c nondsp.c
X
SHAR_EOF
chmod 0644 Makefile.xnx || echo "restore of Makefile.xnx fails"
set `wc -c Makefile.xnx`;Sum=$1
if test "$Sum" != "1305"
then echo original size 1305, current size $Sum;fi
fi
exit 0