home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume22 / gnuchess / patch03 / patch3 next >
Encoding:
Text File  |  1991-08-13  |  14.1 KB  |  539 lines

  1. *** 1.1    1991/08/12 10:41:10
  2. --- ChangeLog    1991/08/12 10:50:22
  3. ***************
  4. *** 1,4 ****
  5. --- 1,31 ----
  6. + Tue Aug  6 18:10:47 1991  Philippe Schnoebelen  (phs@lifia.imag.fr)
  7. +     * Modify handling of Book in Undo (previously, when you
  8. +     backtracked after quitting the book, the program was not able to
  9. +     use it again)
  10. +     * Modify handling of Book in EditBoard and other routines so that
  11. +     the Book is not used if you don't start from the regular initial board.
  12. + Mon Aug  5 17:26:59 1991  Philippe Schnoebelen  (phs@lifia.imag.fr)
  13. +     * Modify parse in gnuchess.c so that a move can be followed by '?'
  14. +     indicating that the program should not play it itself. Such a move
  15. +     is stored with the highest bit raised.
  16. +           Modify OpeningBook in gnuchess.c so that moves with highest bit
  17. +     set are recognized but not played by the program.
  18. +     * Modify the declaration of array PieceList in gnuchess.[ch] to
  19. +     allow for up to 64 men of the same side. Such artificial
  20. +     situations can be built with edit and the program must be able to
  21. +     deal with them.
  22. + Mon Aug 1 10:20 1991 Mike McGann {mwm@hslrswi.hasler.ascom.ch)
  23. +     Split chesstool and xboard versions. Xboard is now
  24. +     gnuchessx and chesstool is gnuchessc.
  25.   Mon Apr 15 10:20 1991 Mike McGann {mwm@hslrswi.hasler.ascom.ch)
  26. +     Changed transposition table to cache positions found in transposition file
  27.       Fix Undo's incorrect handling of promotions.
  28.       Fix win and draw determination bugs.
  29.        Fix bug in algbr that prevented correct display of promotion moves.
  30. *** 1.2    1991/08/12 10:43:46
  31. --- Makefile    1991/08/12 10:50:22
  32. ***************
  33. *** 75,83 ****
  34.   postprint: postprint.o
  35.       $(CC) $(CFLAGS) -o postprint postprint.o
  36.       
  37. ! gnuchessd: gnuchess.c nuxdsp.c
  38. !     $(CC) $(CFLAGS) $(HASH) $(BOOK) -DCHESSTOOL -DDEBUG -o  gnuchessd  nondsp.c gnuchess.c
  39. !     rm nondsp.o gnuchess.o
  40.   
  41.   gnuan.o: gnuan.c gnuchess.h version.h
  42.       $(CC) $(CFLAGS) $(HASH) $(BOOK) -c gnuan.c
  43. --- 75,83 ----
  44.   postprint: postprint.o
  45.       $(CC) $(CFLAGS) -o postprint postprint.o
  46.       
  47. ! gnuchessd:  nondsp.c gnuchess.c
  48. !     $(CC) -Wall -fstrength-reduce -p -g -Dinline="" $(HASH) $(BOOK) -DCHESSTOOL -DDEBUG -o  gnuchessd  nondsp.c gnuchess.c
  49.   
  50.   gnuan.o: gnuan.c gnuchess.h version.h
  51.       $(CC) $(CFLAGS) $(HASH) $(BOOK) -c gnuan.c
  52. *** 1.1    1991/08/12 10:41:10
  53. --- gnuan.c    1991/08/12 10:50:23
  54. ***************
  55. *** 516,521 ****
  56. --- 516,523 ----
  57.     flag.mate = false;
  58.     Sdepth = 0;
  59.     InitializeStats ();
  60. +   if (flag.regularstart)
  61. +     Book = BKBook;
  62.   }
  63.   
  64.   void
  65. *** 1.1    1991/08/12 10:41:10
  66. --- gnuchess.book    1991/08/12 10:50:23
  67. ***************
  68. *** 3901,3903 ****
  69. --- 3901,3951 ----
  70.   d1e2  f6e4
  71.   a1c1  a8c8
  72.   !
  73. + ! Sicilian - Morra Gambit (declined)
  74. + e2e4  c7c5
  75. + d2d4? c5d4
  76. + c2c3  d4d3
  77. + !
  78. + e2e4  c7c5
  79. + d2d4? c5d4
  80. + g1f3  e7e6
  81. + !
  82. + ! Alekhine's Defence
  83. + e2e4  g8f6
  84. + f1c4  f6e4?
  85. + c4f7  e8f7
  86. + d1h5  f7e6
  87. + h5g4  e6d5
  88. + c2c4
  89. + !
  90. + e2e4  g8f6
  91. + f1c4  e7e5
  92. + !
  93. + ! Damiano defence (how to refute it)
  94. + e2e4 e7e5
  95. + g1f3 f7f6?
  96. + f3e5 f6e5
  97. + d1h5 e8e7
  98. + h5e5 e7f7
  99. + f1c4
  100. + !
  101. + ! Two Knights Defence
  102. + e2e4  e7e5
  103. + g1f3  b8c6
  104. + f1c4  g8f6
  105. + f3g5  d7d5
  106. + e4d5  f6d5?
  107. + g5f7  e8f7
  108. + d1f3  f7e6
  109. + b1c3
  110. + !
  111. + ! Hungarian Defence
  112. + e2e4  e7e5
  113. + g1f3  b8c6
  114. + f1c4  f8e7?
  115. + d2d4  e5d4
  116. + c2c3  d4c3
  117. + d1d5  g8h6
  118. + c1h6  e8g8
  119. + h6g7
  120. + !
  121. *** 1.1    1991/08/12 10:41:10
  122. --- gnuchess.c    1991/08/12 10:50:24
  123. ***************
  124. *** 145,151 ****
  125.   char listfile[128] = "";
  126.   struct leaf Tree[2000], *root;
  127.   short TrPnt[maxdepth];
  128. ! short PieceList[2][16], PawnCnt[2][8];
  129.   #define wking PieceList[white][0]
  130.   #define bking PieceList[black][0]
  131.   #define EnemyKing PieceList[c2][0]
  132. --- 145,151 ----
  133.   char listfile[128] = "";
  134.   struct leaf Tree[2000], *root;
  135.   short TrPnt[maxdepth];
  136. ! short PieceList[2][64], PawnCnt[2][8];
  137.   #define wking PieceList[white][0]
  138.   #define bking PieceList[black][0]
  139.   #define EnemyKing PieceList[c2][0]
  140. ***************
  141. *** 320,330 ****
  142.   const short Stcolor[64] =
  143.   {white, white, white, white, white, white, white, white,
  144.    white, white, white, white, white, white, white, white,
  145. !  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  146. !  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  147.    black, black, black, black, black, black, black, black,
  148.    black, black, black, black, black, black, black, black};
  149.   short board[64], color[64];
  150.   static unsigned char nextpos[8][64][64];
  151.   static unsigned char nextdir[8][64][64];
  152.   /*
  153. --- 320,346 ----
  154.   const short Stcolor[64] =
  155.   {white, white, white, white, white, white, white, white,
  156.    white, white, white, white, white, white, white, white,
  157. !  neutral, neutral, neutral, neutral, neutral, neutral, neutral, neutral,
  158. !  neutral, neutral, neutral, neutral, neutral, neutral, neutral, neutral,
  159. !  neutral, neutral, neutral, neutral, neutral, neutral, neutral, neutral,
  160. !  neutral, neutral, neutral, neutral, neutral, neutral, neutral, neutral,
  161.    black, black, black, black, black, black, black, black,
  162.    black, black, black, black, black, black, black, black};
  163.   short board[64], color[64];
  164. + /* nextpos[piece][from-square] , nextdir[piece][from-square] gives vector of positions reachable from from-square 
  165. +     in ppos with piece such that the sequence    
  166. +             ppos = nextpos[piece][from-square];
  167. +             pdir = nextdir[piece][from-square];
  168. +             u = ppos[sq];
  169. +             do {
  170. +                 u = ppos[u];
  171. +                 if(color[u] != neutral) u = pdir[u];
  172. +             } while (sq != u);
  173. +     will generate the sequence of all squares reachable from sq.
  174. +     If the path is blocked u = pdir[sq] will generate the continuation of the sequence in other directions.
  175. + */
  176. +     
  177.   static unsigned char nextpos[8][64][64];
  178.   static unsigned char nextdir[8][64][64];
  179.   /*
  180. ***************
  181. *** 337,342 ****
  182. --- 353,359 ----
  183.   {
  184.     no_piece, pawn, knight, bishop, rook, queen, king, no_piece,
  185.     no_piece, bpawn, knight, bishop, rook, queen, king, no_piece};
  186. + /* data used to generate nextpos/nextdir */
  187.   static const short direc[8][8] =
  188.   {
  189.     0, 0, 0, 0, 0, 0, 0, 0,
  190. ***************
  191. *** 691,696 ****
  192. --- 708,714 ----
  193.     time0 = time ((long *) 0);
  194.     ElapsedTime (1);
  195.     UpdateDisplay (0, 0, 1, 0);
  196. +   flag.regularstart = true;
  197.     Book = BKBook;
  198.   }
  199.   
  200. ***************
  201. *** 800,806 ****
  202.   
  203.         for (i = TrPnt[1]; i < TrPnt[2]; i++)
  204.       pick (i, TrPnt[2] - 1);
  205. !       if (Book != NULL)
  206.       OpeningBook (&hint);
  207.         if (Book != NULL)
  208.       flag.timeout = true;
  209. --- 818,824 ----
  210.   
  211.         for (i = TrPnt[1]; i < TrPnt[2]; i++)
  212.       pick (i, TrPnt[2] - 1);
  213. !       if (flag.regularstart && Book != NULL)
  214.       OpeningBook (&hint);
  215.         if (Book != NULL)
  216.       flag.timeout = true;
  217. ***************
  218. *** 862,868 ****
  219.     if (rpt >= 2)
  220.       {
  221.         root->flags |= draw;
  222. !       DRAW = "Repitition";
  223.       }
  224.     if (score < -12000)
  225.       {
  226. --- 880,886 ----
  227.     if (rpt >= 2)
  228.       {
  229.         root->flags |= draw;
  230. !       DRAW = "Repetition";
  231.       }
  232.     if (score < -12000)
  233.       {
  234. ***************
  235. *** 931,937 ****
  236.     while ((c = getc (fd)) == ' ') ;
  237.     i = 0;
  238.     s[0] = (char) c;
  239. !   while (c != ' ' && c != '\n' && c != EOF)
  240.       s[++i] = (char) (c = getc (fd));
  241.     s[++i] = '\0';
  242.     if (c == EOF)
  243. --- 949,955 ----
  244.     while ((c = getc (fd)) == ' ') ;
  245.     i = 0;
  246.     s[0] = (char) c;
  247. !   while (c != '?' && c != ' ' && c != '\t' && c != '\n' && c != EOF)
  248.       s[++i] = (char) (c = getc (fd));
  249.     s[++i] = '\0';
  250.     if (c == EOF)
  251. ***************
  252. *** 954,959 ****
  253. --- 972,981 ----
  254.         r2 = s[3] - '1';
  255.         *mv = (locn (r1, c1) << 8) | locn (r2, c2);
  256.       }
  257. +   if (c == '?') {        /* Bad move, not for the program to play */
  258. +     *mv |= 0x8000;        /* Flag it ! */
  259. +     c = getc(fd);
  260. +  }
  261.     return (1);
  262.   }
  263.   
  264. ***************
  265. *** 965,971 ****
  266.      into an unsigned integer format indicating the from and to square. Create
  267.      a linked list of opening lines of play, with entry->next pointing to the
  268.      next line and entry->move pointing to a chunk of memory containing the
  269. !    moves. More Opening lines of up to 256 half moves may be added to
  270.      gnuchess.book.
  271.   */
  272.   #ifndef BOOK
  273. --- 987,993 ----
  274.      into an unsigned integer format indicating the from and to square. Create
  275.      a linked list of opening lines of play, with entry->next pointing to the
  276.      next line and entry->move pointing to a chunk of memory containing the
  277. !    moves. More Opening lines of up to 100 half moves may be added to
  278.      gnuchess.book.
  279.   */
  280.   #ifndef BOOK
  281. ***************
  282. *** 1036,1042 ****
  283.     unsigned short m, *mp;
  284.     unsigned r, r0;
  285.     struct BookEntry *p;
  286.     srand ((unsigned int) time ((long *) 0));
  287.     r0 = m = 0;
  288.     p = Book;
  289. --- 1058,1064 ----
  290.     unsigned short m, *mp;
  291.     unsigned r, r0;
  292.     struct BookEntry *p;
  293. !   
  294.     srand ((unsigned int) time ((long *) 0));
  295.     r0 = m = 0;
  296.     p = Book;
  297. ***************
  298. *** 1044,1057 ****
  299.       {
  300.         mp = p->mv;
  301.         for (j = 1; j <= GameCnt; j++)
  302. !     if (GameList[j].gmove != *(mp++))
  303.         break;
  304. !       if (j > GameCnt)
  305.       if ((r = urand ()) > r0)
  306.         {
  307.           r0 = r;
  308. !         m = *mp;
  309. !         *hint = *(++mp);
  310.         }
  311.         p = p->next;
  312.       }
  313. --- 1066,1080 ----
  314.       {
  315.         mp = p->mv;
  316.         for (j = 1; j <= GameCnt; j++)
  317. !     if ( GameList[j].gmove != (*(mp++) & 0x7FFF) ) {
  318.         break;
  319. !        }
  320. !       if ( (j > GameCnt) && ((*mp & 0x8000) == 0) )
  321.       if ((r = urand ()) > r0)
  322.         {
  323.           r0 = r;
  324. !         m = (*mp & 0x7FFF);
  325. !         *hint = (*(++mp) & 0x7FFF);
  326.         }
  327.         p = p->next;
  328.       }
  329. *** 1.1    1991/08/12 10:41:10
  330. --- gnuchess.h    1991/08/12 10:50:24
  331. ***************
  332. *** 109,114 ****
  333. --- 109,115 ----
  334.     short mate;        /* the game is over */
  335.     short post;        /* show principle variation */
  336.     short quit;        /* quit/exit gnuchess */
  337. +   short regularstart;    /* did the game start from standard initial board ? */
  338.     short reverse;    /* reverse board display */
  339.     short bothsides;    /* computer plays both sides */
  340.     short hash;        /* enable/disable transposition table */
  341. ***************
  342. *** 123,129 ****
  343.   extern char savefile[128], listfile[128];
  344.   extern short TrPnt[maxdepth];
  345.   extern short board[64], color[64];
  346. ! extern short PieceList[2][16], PawnCnt[2][8];
  347.   extern short castld[2], Mvboard[64];
  348.   extern short svalue[64];
  349.   extern struct flags flag;
  350. --- 124,130 ----
  351.   extern char savefile[128], listfile[128];
  352.   extern short TrPnt[maxdepth];
  353.   extern short board[64], color[64];
  354. ! extern short PieceList[2][64], PawnCnt[2][8];
  355.   extern short castld[2], Mvboard[64];
  356.   extern short svalue[64];
  357.   extern struct flags flag;
  358. ***************
  359. *** 136,142 ****
  360.   extern struct GameRec GameList[200];
  361.   extern short GameCnt, Game50;
  362.   extern short Sdepth, MaxSearchDepth;
  363. ! extern struct BookEntry *Book;
  364.   extern struct TimeControlRec TimeControl;
  365.   extern short TCflag, TCmoves, TCminutes, OperatorTime;
  366.   extern const short otherside[3];
  367. --- 137,143 ----
  368.   extern struct GameRec GameList[200];
  369.   extern short GameCnt, Game50;
  370.   extern short Sdepth, MaxSearchDepth;
  371. ! extern struct BookEntry *Book, *BKBook;
  372.   extern struct TimeControlRec TimeControl;
  373.   extern short TCflag, TCmoves, TCminutes, OperatorTime;
  374.   extern const short otherside[3];
  375. *** 1.3    1991/08/12 10:43:46
  376. --- nondsp.c    1991/08/12 10:50:24
  377. ***************
  378. *** 148,153 ****
  379. --- 148,160 ----
  380.           {
  381.             mvstr[0][4] = mvstr[1][2] = mvstr[2][m3p] = qxx[flag & pmask];
  382.             mvstr[1][3] = mvstr[2][m3p + 1] = mvstr[0][5] = '\0';
  383. + #ifdef CHESSTOOL
  384. +           mvstr[3][0] = mvstr[0][0]; /* Allow e7e8 for chesstool */
  385. +           mvstr[3][1] = mvstr[0][1];
  386. +           mvstr[3][2] = mvstr[0][2];
  387. +           mvstr[3][3] = mvstr[0][3];
  388. +           mvstr[3][4] = '\0';
  389. + #endif
  390.           }
  391.         mvstr[2][m3p] = mvstr[1][2] = '\0';
  392.       }
  393. ***************
  394. *** 340,345 ****
  395. --- 347,354 ----
  396.     short a, r, c, sq, i;
  397.     char s[80];
  398.   
  399. +   flag.regularstart = false;
  400. +   Book = NULL;
  401.     ClrScreen ();
  402.     UpdateDisplay (0, 0, 1, 0);
  403.     printz (".   exit to main\n");
  404. ***************
  405. *** 802,807 ****
  406. --- 811,818 ----
  407.           }
  408.       }
  409.         GameCnt = 0;
  410. +       flag.regularstart = false;
  411. +       Book = NULL;
  412.         fgets (fname, 256, fd);
  413.         fgets (fname, 256, fd);
  414.         fgets (fname, 256, fd);
  415. ***************
  416. *** 863,868 ****
  417. --- 874,881 ----
  418.     if ((fd = fopen (fname, "r")) != NULL)
  419.       {
  420.         NewGame ();
  421. +       flag.regularstart = false;
  422. +       Book = NULL;
  423.         fgets (fname, 256, fd);
  424.         fname[6] = '\0';
  425.         if (strcmp (fname, "xboard"))
  426. ***************
  427. *** 1057,1062 ****
  428. --- 1070,1077 ----
  429.     ShowSidetoMove();
  430.     UpdateDisplay (0, 0, 1, 0);
  431.     InitializeStats ();
  432. +   if (flag.regularstart)
  433. +     Book = BKBook;
  434.   }
  435.   
  436.   void
  437. *** 1.1    1991/08/12 10:41:10
  438. --- nuxdsp.c    1991/08/12 10:50:24
  439. ***************
  440. *** 381,386 ****
  441. --- 381,388 ----
  442.     short a, r, c, sq, i;
  443.     char s[80];
  444.   
  445. +   flag.regularstart = false;
  446. +   Book = NULL;
  447.     ClrScreen ();
  448.     UpdateDisplay (0, 0, 1, 0);
  449.     gotoXY (TAB, 3);
  450. ***************
  451. *** 1137,1142 ****
  452. --- 1139,1146 ----
  453.       }
  454.       }
  455.     GameCnt = 0;
  456. +   flag.regularstart = false;
  457. +   Book = NULL;
  458.     fgets (fname, 256, fd);
  459.     fgets (fname, 256, fd);
  460.     fgets (fname, 256, fd);
  461. ***************
  462. *** 1206,1211 ****
  463. --- 1210,1217 ----
  464.     if ((fd = fopen (fname, "r")) != NULL)
  465.       {
  466.         NewGame ();
  467. +       flag.regularstart = false;
  468. +       Book = NULL;
  469.         fgets (fname, 256, fd);
  470.         fname[6] = '\0';
  471.         if (strcmp (fname, "xboard"))
  472. ***************
  473. *** 1423,1428 ****
  474. --- 1429,1436 ----
  475.     ShowSidetoMove ();
  476.     UpdateDisplay (0, 0, 1, 0);
  477.     InitializeStats ();
  478. +   if (flag.regularstart)
  479. +     Book = BKBook;
  480.   }
  481.   
  482.   void
  483. *** 1.1    1991/08/12 10:41:10
  484. --- uxdsp.c    1991/08/12 10:50:24
  485. ***************
  486. *** 344,349 ****
  487. --- 344,351 ----
  488.     short a, r, c, sq, i;
  489.     char s[80];
  490.   
  491. +   flag.regularstart = false;
  492. +   Book = NULL;
  493.     ClrScreen ();
  494.     UpdateDisplay (0, 0, 1, 0);
  495.     gotoXY (TAB, 3);
  496. ***************
  497. *** 978,983 ****
  498. --- 980,987 ----
  499.       }
  500.       }
  501.     GameCnt = 0;
  502. +   flag.regularstart = false;
  503. +   Book = NULL;
  504.     fgets (fname, 256, fd);
  505.     fgets (fname, 256, fd);
  506.     fgets (fname, 256, fd);
  507. ***************
  508. *** 1049,1054 ****
  509. --- 1053,1060 ----
  510.     if ((fd = fopen (fname, "r")) != NULL)
  511.       {
  512.         NewGame ();
  513. +       flag.regularstart = false;
  514. +       Book = NULL;
  515.         fgets (fname, 256, fd);
  516.         fname[6] = '\0';
  517.         if (strcmp (fname, "xboard"))
  518. ***************
  519. *** 1266,1271 ****
  520. --- 1272,1279 ----
  521.     ShowSidetoMove();
  522.     UpdateDisplay (0, 0, 1, 0);
  523.     InitializeStats ();
  524. +   if (flag.regularstart)
  525. +     Book = BKBook;
  526.   }
  527.   
  528.   void
  529.