home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gnushogi-1.1 / src / nondsp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-16  |  17.9 KB  |  798 lines

  1. /*
  2.  * nondsp.c - UNIX & MSDOS AND NON-DISPLAY interface for GNU SHOGI
  3.  *
  4.  * Copyright (c) 1990 Matthias Mutz
  5.  *
  6.  * GNU SHOGI is based on GNU CHESS
  7.  *
  8.  * Copyright (c) 1988,1989,1990 John Stanback
  9.  * Copyright (c) 1992 Free Software Foundation
  10.  *
  11.  * This file is part of GNU SHOGI.
  12.  *
  13.  * GNU Shogi is free software; you can redistribute it and/or modify
  14.  * it under the terms of the GNU General Public License as published by
  15.  * the Free Software Foundation; either version 1, or (at your option)
  16.  * any later version.
  17.  *
  18.  * GNU Shogi is distributed in the hope that it will be useful,
  19.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  * GNU General Public License for more details.
  22.  *
  23.  * You should have received a copy of the GNU General Public License
  24.  * along with GNU Shogi; see the file COPYING.  If not, write to
  25.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  */
  27. extern int EADD,EGET;
  28. #include <ctype.h>
  29. #include <signal.h>
  30. #if defined THINK_C
  31. #include <time.h>
  32. #elif defined MSDOS
  33. #include <dos.h>
  34. #include <conio.h>
  35. #include <stdlib.h>
  36. #include <string.h>
  37. #include <time.h>
  38. #else
  39. #include <sys/param.h>
  40. #include <sys/types.h>
  41. #include <sys/file.h>
  42. #include <sys/ioctl.h>
  43. void TerminateSearch (int), Die (int);
  44.  
  45. #endif /* MSDOS */
  46.  
  47. #include "gnushogi.h"
  48.  
  49. #ifdef DEBUG
  50. short int debuglevel = 0;
  51. #endif /* DEBUG */
  52. unsigned short int MV[MAXDEPTH];
  53. int MSCORE;
  54.  
  55. #if defined XSHOGI
  56. short int xshogi = 1;
  57.  
  58. #else
  59. short int xshogi = 0;
  60.  
  61. #endif /* XSHOGI */
  62. extern char mvstr[4][6];
  63. int mycnt1, mycnt2;
  64. char *DRAW;
  65. extern char *InPtr;
  66. extern short int pscore[];
  67.  
  68. void
  69. Initialize (void)
  70. {
  71.   mycnt1 = mycnt2 = 0;
  72. #if defined XSHOGI && !defined THINK_C
  73. #ifndef SYSV
  74.   setlinebuf (stdout);
  75. #else
  76.   setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
  77. #endif
  78.   printf (CP[43]);        /* Shogi */
  79. #endif XSHOGI
  80. #ifdef HARDTIMELIMIT
  81.   if (!TCflag && (MaxResponseTime == 0))
  82.     MaxResponseTime = 15L*100L;
  83. #endif
  84. }
  85.  
  86. void
  87. ExitChess (void)
  88. {
  89.   signal (SIGTERM, SIG_IGN);
  90.   ListGame ();
  91.   exit (0);
  92. }
  93.  
  94. #ifndef MSDOS            /* never called!!! */
  95. void
  96. Die (int sig)
  97. {
  98.   char s[80];
  99.  
  100.   ShowMessage (CP[31]);        /*Abort?*/
  101.   scanz ("%s", s);
  102.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  103.     ExitChess ();
  104. }
  105.  
  106. #endif /* MSDOS */
  107.  
  108. void
  109. TerminateSearch (int sig)
  110. {
  111. #ifdef MSDOS
  112.   sig++;            /* shut up the compiler */
  113. #endif /* MSDOS */
  114.   if (!flag.timeout)
  115.     flag.musttimeout = true;
  116.   flag.bothsides = false;
  117. }
  118.  
  119.  
  120.  
  121.  
  122. void
  123. help (void)
  124. {
  125.   ClrScreen ();
  126.   /*printz ("SHOGI command summary\n");*/
  127.   printz (CP[40]);
  128.   printz ("----------------------------------------------------------------\n");
  129.   /*printz ("7g7f      move from 7g to 7f      quit      Exit Shogi\n");*/
  130.   printz (CP[158]);
  131.   /*printz ("S6h       move silver to 6h       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  132.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  133.   /*printz ("2d2c+     move from 2d to 2c and promote\n");*/
  134.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  135.   /*printz ("P*5e      drop pawn to 5e         easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  136.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  137.   /*printz ("                                  hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  138.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  139.   /*printz ("bd        redraw board            reverse   board display\n");*/
  140.   printz (CP[130]);
  141.   /*printz ("list      game to shogi.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount);*/
  142.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount,booksize);
  143.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  144.   printz (CP[200]);
  145.   /*printz ("edit      edit board              force     enter game moves\n");*/
  146.   printz (CP[153]);
  147.   /*printz ("switch    sides with computer     both      computer match\n");*/
  148.   printz (CP[194]);
  149.   /*printz ("black     computer plays black    white     computer plays white\n");*/
  150.   printz (CP[202]);
  151.   /*printz ("depth     set search depth        clock     set time control\n");*/
  152.   printz (CP[149]);
  153.   /*printz ("post      principle variation     hint      suggest a move\n");*/
  154.   printz (CP[177]);
  155.   /*printz ("save      game to file            get       game from file\n");*/
  156.   printz (CP[188]);
  157.   /*printz ("random    randomize play          new       start new game\n");*/
  158.   printz (CP[181]);
  159.   printz ("----------------------------------------------------------------\n");
  160.   /*printz ("Computer: %-12s Opponent:            %s\n",*/
  161.   printz (CP[46],
  162.       ColorStr[computer], ColorStr[opponent]);
  163.   /*printz ("Depth:    %-12d Response time:       %d sec\n",*/
  164.   printz (CP[51],
  165.       MaxSearchDepth, MaxResponseTime/100);
  166.   /*printz ("Random:   %-12s Easy mode:           %s\n",*/
  167.   printz (CP[99],
  168.       (dither) ? CP[93] : CP[92], (flag.easy) ? CP[93] : CP[92]);
  169.   /*printz ("Beep:     %-12s Transposition file: %s\n",*/
  170.   printz (CP[36],
  171.       (flag.beep) ? CP[93] : CP[92], (flag.hash) ? CP[93] : CP[92]);
  172.   /*printz ("Tsume:    %-12s\n")*/
  173.   printz (CP[232], 
  174.       (flag.tsume) ? CP[93] : CP[92]);
  175.   /*printz ("Time Control %s %d moves %d seconds %d opr %d depth\n", (TCflag) ? "ON" : "OFF",*/
  176.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  177.       TimeControl.moves[black], TimeControl.clock[black] / 100, TCadd/100, MaxSearchDepth);
  178.   signal (SIGINT, TerminateSearch);
  179. #if !defined MSDOS && !defined THINK_C
  180.   signal (SIGQUIT, TerminateSearch);
  181. #endif /* MSDOS */
  182. }                 
  183.  
  184.  
  185. void
  186. EditBoard (void)
  187.  
  188. /*
  189.  * Set up a board position. Pieces are entered by typing the piece followed
  190.  * by the location. For example, Nf3 will place a knight on square f3.
  191.  */
  192.  
  193. {
  194.   short a, r, c, sq, i, found;
  195.   char s[80];
  196.  
  197.   flag.regularstart = true;
  198.   Book = BOOKFAIL;
  199.   ClrScreen ();
  200.   UpdateDisplay (0, 0, 1, 0);
  201.   /*printz (".   exit to main\n");*/
  202.   printz (CP[29]);
  203.   /*printz ("#   clear board\n");*/
  204.   printz (CP[28]);
  205.   /*printz ("c   change sides\n");*/
  206.   printz (CP[136]);
  207.   /*printz ("enter piece & location: \n");*/
  208.   printz (CP[155]);
  209.  
  210.   a = black;
  211.   do
  212.     {
  213.       scanz ("%s", s);
  214.       found=0;
  215.       if (s[0] == CP[28][0])    /*#*/
  216.     { short side;
  217.       for (sq = 0; sq < NO_SQUARES; sq++)
  218.         {
  219.           board[sq] = no_piece;
  220.           color[sq] = neutral;
  221.         };
  222.       ClearCaptured ();
  223.     }
  224.       if (s[0] == CP[136][0])    /*c*/
  225.     a = otherside[a];
  226.       if ( s[1] == '*' )
  227.     { 
  228.       for ( i = pawn; i <= king; i++)
  229.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  230.               { 
  231.               Captured[a][i]++; 
  232.                 found=1;
  233.         break;
  234.            } 
  235.       c = -1;
  236.           r = -1;
  237.     }
  238.       else
  239.     {
  240.           c = '9' - s[1];
  241.           r = 'i' - s[2];
  242.     }
  243.       if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
  244.     {
  245.       sq = locn (r, c);
  246.       color[sq] = a;
  247.       board[sq] = no_piece;
  248.       for (i = no_piece; i <= king; i++)
  249.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  250.           { 
  251.         if ( s[3] == '+' )
  252.           board[sq] = promoted[i];
  253.         else
  254.           board[sq] = i;
  255.         found=1;
  256.         break;
  257.           }
  258.       if (found==0) color[sq] = neutral;    
  259.     }
  260.   } while (s[0] != CP[29][0]);
  261.   for (sq = 0; sq < NO_SQUARES; sq++)
  262.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  263.   GameCnt = 0;
  264.   Game50 = 1;
  265.   ZeroRPT ();
  266.   Sdepth = 0;
  267.   InitializeStats ();
  268.   ClrScreen ();
  269.   UpdateDisplay (0, 0, 1, 0);
  270. }
  271.  
  272. void
  273. SetupBoard (void)
  274.  
  275. /*
  276.  * Set up a board position.
  277.  * Nine lines of nine characters are used to setup the board. 9a-1a is the
  278.  * first line. White pieces are  represented  by  uppercase characters.
  279.  */
  280.  
  281. {
  282.   short r, c, sq, i;
  283.   char ch;
  284.   char s[80];
  285.  
  286.   NewGame ();
  287.  
  288.   gets (s);            /* skip "setup" command */
  289.   for (r = NO_ROWS-1; r >= 0; r--)
  290.     {
  291.       gets (s);
  292.       for (c = 0; c <= (NO_COLS-1); c++)
  293.     {
  294.       ch = s[c];
  295.       sq = locn (r, c);
  296.       color[sq] = neutral;
  297.       board[sq] = no_piece;
  298.       for (i = no_piece; i <= king; i++)
  299.         if (ch == pxx[i])
  300.           {
  301.         color[sq] = white;
  302.         board[sq] = i;
  303.         break;
  304.           }
  305.         else if (ch == qxx[i])
  306.           {
  307.         color[sq] = black;
  308.         board[sq] = i;
  309.         break;
  310.           }
  311.     }
  312.     }
  313.   for (sq = 0; sq < NO_SQUARES; sq++)
  314.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  315.   InitializeStats ();
  316.   ClrScreen ();
  317.   UpdateDisplay (0, 0, 1, 0);
  318.   /*printz ("Setup successful\n");*/
  319.   printz (CP[106]);
  320. }
  321.  
  322. void
  323. ShowDepth (char ch)
  324. {
  325. #ifdef MSDOS
  326.   ch++;                /* shut up the compiler */
  327. #endif /* MSDOS */
  328. #if !defined BAREBONES
  329.   printz (CP[53], Sdepth, ch);    /*Depth= %d%c*/
  330.   printz ("\n");
  331. #endif
  332. }
  333.  
  334.  
  335. void
  336. ShowLine (short unsigned int *bstline)
  337. {
  338.   register int i;
  339.  
  340.   for (i = 1; bstline[i] > 0; i++)
  341.     {
  342.       if ((i > 1) && (i % 8 == 1))
  343.     printf ("\n                          ");
  344.       algbr ((short) (bstline[i] >> 8), (short) (bstline[i] & 0xFF), false);
  345.       printf ("%5s ", mvstr[0]);
  346.     }
  347.   printf ("\n");
  348. }
  349.  
  350. void
  351. ShowResults (short int score, short unsigned int *bstline, char ch)
  352. {
  353.   if (flag.post)
  354.     {
  355.       ElapsedTime (2);
  356.       printf ("%2d%c %6d %4ld %8ld  ", Sdepth, ch, score, et / 100, NodeCnt);
  357.       ShowLine (bstline);
  358.     }
  359. }
  360.  
  361. void
  362. SearchStartStuff (short int side)
  363. {
  364.   signal (SIGINT, TerminateSearch);
  365. #if !defined MSDOS && !defined THINK_C
  366.   signal (SIGQUIT, TerminateSearch);
  367. #endif /* MSDOS */
  368.   if (flag.post)
  369.     {
  370.       printf (CP[123],
  371.            GameCnt/2+1,
  372.            ResponseTime, TimeControl.clock[side]);
  373.     }
  374. }
  375. void
  376. OutputMove (void)
  377. {
  378. #ifdef DEBUG11
  379.   if (1)
  380.     {
  381.       FILE *D;
  382.       extern unsigned short int PrVar[];
  383.       char d[80];
  384.       int r, c, l, i;
  385.       D = fopen ("/tmp/DEBUGA", "a+");
  386.       fprintf (D, "inout move is %s\n", mvstr[0]);
  387.       strcpy (d, mvstr[0]);
  388.       for (i = 1; PrVar[i] > 0; i++)
  389.     {
  390.       algbr ((short) (PrVar[i] >> 8), (short) (PrVar[i] & 0xFF), false);
  391.       fprintf (D, "%5s ", mvstr[0]);
  392.     }
  393.       fprintf (D, "\n");
  394.  
  395.       fprintf (D, "\n current board is\n");
  396.       for (r = (NO_ROWS-1); r >= 0; r--)
  397.     {
  398.       for (c = 0; c <= (NO_COLS-1); c++)
  399.         {
  400.           l = locn (r, c);
  401.           if (color[l] == neutral)
  402.         fprintf (D, " -");
  403.           else if (color[l] == black)
  404.         fprintf (D, " %c", qxx[board[l]]);
  405.           else
  406.         fprintf (D, " %c", pxx[board[l]]);
  407.         }
  408.       fprintf (D, "\n");
  409.     }
  410.       fprintf (D, "\n");
  411.       fclose (D);
  412.       strcpy (mvstr[0], d);
  413.     }
  414. #endif
  415.   if (flag.illegal) {printf("%s\n",CP[225]);return;}
  416.   if (mvstr[0][0] == '\0') goto nomove;
  417.   printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  418. #ifdef notdef /* optional pass best line to frontend with move */
  419.   if (flag.post)
  420.     {
  421.       register int i;
  422.  
  423.       printz (" %6d%c ", MSCORE, MV[30]);
  424.       for (i = 1; MV[i] > 0; i++)
  425.     {
  426.       algbr ((short) (MV[i] >> 8), (short) (MV[i] & 0xFF), false);
  427.       printz ("%5s ", mvstr[0]);
  428.     }
  429.     }
  430.   printz ("\n");
  431. #endif
  432. nomove:
  433.   if ((root->flags & draw)||(root->score == -(SCORE_LIMIT+999))||
  434.       (root->score == (SCORE_LIMIT+998))) goto summary;
  435.   if (flag.post)
  436.     {
  437.       short h, l, t;
  438.  
  439.       h = TREE;
  440.       l = 0;
  441.       t = TREE >> 1;
  442.       while (l != t)
  443.     {
  444.       if (Tree[t].f || Tree[t].t)
  445.         l = t;
  446.       else
  447.         h = t;
  448.       t = (l + h) >> 1;
  449.     }
  450.       /*printf ("Nodes %ld Tree %d Eval %ld Rate %ld RS high %ld low %ld\n",*/
  451.       printf (CP[89],GenCnt,NodeCnt,t,EvalNodes,(et>100)?(NodeCnt/(et/100)):0,EADD,EGET,reminus,replus);
  452.       /*printf ("Hin/Hout/Coll/Fin/Fout = %ld/%ld/%ld/%ld/%ld\n",*/
  453.       printf (CP[71],
  454.            HashAdd, HashCnt, THashCol, HashCol,FHashCnt, FHashAdd);
  455.     }
  456.   UpdateDisplay (root->f, root->t, 0, root->flags);
  457.   if ( !xshogi )
  458.     {
  459.       /*printf ("My move is: %s\n", mvstr[0]);*/
  460.       printf (CP[83], mvstr[0]);
  461.       if (flag.beep)
  462.         printz ("%c", 7);
  463.     }
  464.  summary:
  465.   if (root->flags & draw)
  466.     /*    printf ("Drawn game!\n");*/
  467.     printf (CP[57]);
  468.   else if (root->score == -(SCORE_LIMIT+999))
  469.     printf("%s mates!\n",ColorStr[opponent]);
  470.   else if (root->score == (SCORE_LIMIT+998))
  471.     printf("%s mates!\n",ColorStr[computer]);
  472. #if !defined BAREBONES
  473. #ifdef VERYBUGGY
  474.   else if (root->score < -SCORE_LIMIT)
  475.     printf("%s has a forced mate!\n",ColorStr[opponent]);
  476.   else if (root->score > SCORE_LIMIT)
  477.     printf("%s has a forced mate!\n",ColorStr[computer]);
  478. #endif /*VERYBUGGY*/
  479. #endif /* BAREBONES */
  480. }
  481.  
  482. void
  483. ClrScreen (void)
  484. {
  485. #if !defined BAREBONES
  486.   printz ("\n");
  487. #endif
  488. }
  489.  
  490. void
  491. UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
  492. {
  493.  
  494.   short r, c, l, m;
  495.  
  496.   if (redraw && !xshogi)
  497.     {
  498.       printz ("\n");
  499.       r = (short)(TimeControl.clock[black] / 6000);
  500.       c = (short)((TimeControl.clock[black] % 6000) / 100);
  501.       l = (short)(TimeControl.clock[white] / 6000);
  502.       m = (short)((TimeControl.clock[white] % 6000) / 100);
  503.       /*printz ("Black %d:%02d  White %d:%02d\n", r, c, l, m);*/
  504.       printz (CP[116], r, c, l, m);
  505.       printz ("\n");
  506.       for (r = (NO_ROWS-1); r >= 0; r--)
  507.     {
  508.       for (c = 0; c <= (NO_COLS-1); c++)
  509.         { char pc;
  510.           l = ((flag.reverse) ? locn ((NO_ROWS-1) - r, (NO_COLS-1) - c) : locn (r, c));
  511.           pc = (is_promoted[board[l]] ? '+' : ' ');
  512.           if (color[l] == neutral)
  513.         printz (" -");
  514.           else if (color[l] == black)
  515.         printz ("%c%c", pc, qxx[board[l]]);
  516.           else
  517.         printz ("%c%c", pc, pxx[board[l]]);
  518.         }
  519.       printz ("\n");
  520.     }
  521.       printz ("\n");
  522.       {  
  523.     short side;
  524.     for (side = black; side <= white; side++)
  525.       { short piece, c; 
  526.         printz((side==black)?"black ":"white ");
  527.             for (piece = pawn; piece <= king; piece++)
  528.           if (c = Captured[side][piece]) 
  529.         printz("%i%c ",c,pxx[piece]);
  530.             printz("\n");
  531.           };
  532.       }
  533.     }
  534. }
  535.  
  536. void
  537. skip ()
  538. {
  539.   while (*InPtr != ' ')
  540.     InPtr++;
  541.   while (*InPtr == ' ')
  542.     InPtr++;
  543. }
  544. void
  545. skipb ()
  546. {
  547.   while (*InPtr == ' ')
  548.     InPtr++;
  549. }
  550.  
  551. void
  552. ShowMessage (char *s)
  553. {
  554.   printf("%s\n", s);
  555. }
  556.  
  557. void
  558. ShowSidetoMove (void)
  559. {
  560. }
  561.  
  562. void
  563. PromptForMove (void)
  564. {
  565. #if !defined BAREBONES
  566.   /*printz ("\nYour move is? ");*/
  567.   printz (CP[124]);
  568. #endif /* BAREBONES */
  569. }
  570.  
  571.  
  572. void
  573. ShowCurrentMove (short int pnt, short int f, short int t)
  574. {
  575. #ifdef MSDOS
  576.   f++;
  577.   t++;
  578.   pnt++;            /* shut up the compiler */
  579. #endif /* MSDOS */
  580. }
  581.  
  582. void
  583. ChangeAlphaWindow (void)
  584. {
  585.   printz ("WAwindow: ");
  586.   scanz ("%hd", &WAwindow);
  587.   printz ("BAwindow: ");
  588.   scanz ("%hd", &BAwindow);
  589. }
  590.  
  591. void
  592. ChangeBetaWindow (void)
  593. {
  594.   printz ("WBwindow: ");
  595.   scanz ("%hd", &WBwindow);
  596.   printz ("BBwindow: ");
  597.   scanz ("%hd", &BBwindow);
  598. }
  599.  
  600. void
  601. GiveHint (void)
  602. {
  603.   if (hint)
  604.     {
  605.       algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
  606.       printf(CP[72], mvstr[0]);    /*hint*/
  607.     }
  608.   else
  609.     printz (CP[223]);
  610. }
  611.  
  612. void
  613. SelectLevel (char *sx)
  614. {
  615.  
  616.   char T[NO_SQUARES], *p, *q;
  617.  
  618.   if((p = strstr(sx,CP[169]))!=NULL) p += strlen(CP[169]);
  619.   else if((p = strstr(sx,CP[217]))!=NULL) p += strlen(CP[217]);
  620.   strcat(sx,"XX");
  621.   q = T; *q = '\0';
  622.   for(;*p != 'X';*q++ = *p++);
  623.   *q = '\0';
  624. /* line empty ask for input */
  625.   if(!T[0]){ printz (CP[61]); gets(T); strcat(T,"XX"); }
  626. /* skip blackspace */
  627.   for (p = T; *p == ' '; p++) ;
  628. /* could be moves or a fischer clock */
  629.   if(*p == 'f') { /* its a fischer clock game */
  630.     p++;
  631.     TCminutes = (short)strtol(p,&q,10);
  632.     TCadd = (short)strtol(q,NULL,10) *100;
  633.     TCseconds = 0;
  634.     TCmoves = 50;
  635.   } else { /* regular game */
  636.   TCadd = 0;
  637.   TCmoves = (short)strtol (p, &q, 10);
  638.   TCminutes = (short)strtol (q, &q, 10);
  639.   if (*q == ':')
  640.     TCseconds = (short)strtol (q + 1, (char **) NULL, 10);
  641.   else
  642.     TCseconds = 0;
  643. #ifdef OPERATORTIME
  644.   printz (CP[94]);
  645.   scanz ("%hd", &OperatorTime);
  646. #endif
  647.   if (TCmoves == 0) {
  648.     TCflag = false;
  649.     MaxResponseTime = TCminutes*60L*100L + TCseconds*100L;
  650.     TCminutes = TCseconds = 0;
  651.   } else {
  652.     TCflag = true;
  653.     MaxResponseTime = 0;
  654.   }
  655. }
  656.   TimeControl.clock[black] = TimeControl.clock[white] = 0;
  657.   SetTimeControl ();
  658. }
  659.  
  660. #ifdef DEBUG
  661. void
  662. ChangeDbLev (void)
  663. {
  664.   printz (CP[146]);
  665.   scanz ("%hd", &debuglevel);
  666. }
  667.  
  668. #endif /* DEBUG */
  669.  
  670. void
  671. ChangeSearchDepth (void)
  672. {
  673.   printz ("depth= ");
  674.   scanz ("%hd", &MaxSearchDepth);
  675.   TCflag = !(MaxSearchDepth > 0);
  676. }
  677.  
  678. void
  679. ChangeHashDepth (void)
  680. {
  681.   printz ("hashdepth= ");
  682.   scanz ("%hd", &HashDepth);
  683.   printz ("MoveLimit= ");
  684.   scanz ("%hd", &HashMoveLimit);
  685. }
  686.  
  687. void
  688. SetContempt (void)
  689. {
  690.   printz ("contempt= ");
  691.   scanz ("%hd", &contempt);
  692. }
  693.  
  694. void
  695. ChangeXwindow (void)
  696. {
  697.   printz ("xwndw= ");
  698.   scanz ("%hd", &xwndw);
  699. }
  700.  
  701. void
  702. ShowPostnValue (short int sq)
  703.  
  704. /*
  705.  * must have called ExaminePosition() first
  706.  */
  707.  
  708. {
  709.   short score;
  710.   score = ScorePosition (color[sq]);
  711.   if (color[sq] != neutral){
  712.     printz ("%3d%c ", svalue[sq],(color[sq] == white)?'b':'w');}
  713.   else
  714.     printz(" *   ");
  715. }
  716.  
  717. void
  718. DoDebug (void)
  719. {
  720.   short c, p, sq, tp, tc, tsq, score,j,k;
  721.   char s[40];
  722.  
  723.   ExaminePosition ();
  724.   ShowMessage (CP[65]);
  725.   scanz ("%s", s);
  726.   c = neutral;
  727.   if (s[0] == CP[9][0] || s[0] == CP[9][1])     /* w W*/ c = black;
  728.   if (s[0] == CP[9][2] || s[0] == CP[9][3])     /*b B*/ c = white;
  729.   for (p = king; p > no_piece; p--)
  730.     if ((s[1] == pxx[p]) || (s[1] == qxx[p])) break;
  731.   if(p > no_piece)
  732.   for(j=(NO_ROWS-1);j>=0;j--){
  733.   for(k=0;k<(NO_COLS);k++){
  734.       sq=j*(NO_COLS)+k;
  735.       tp = board[sq];
  736.       tc = color[sq];
  737.       board[sq] = p;
  738.       color[sq] = c;
  739.       tsq = PieceList[c][1];
  740.       PieceList[c][1] = sq;
  741.       ShowPostnValue (sq);
  742.       PieceList[c][1] = tsq;
  743.       board[sq] = tp;
  744.       color[sq] = tc;
  745.     }
  746.       printz("\n");
  747.     }                                
  748.   score = ScorePosition (opponent);
  749.   for(j=(NO_ROWS-1);j>=0;j--){
  750.   for(k=0;k<(NO_COLS);k++){
  751.       sq=j*(NO_COLS)+k;
  752.       if (color[sq] != neutral){
  753.         printz ("%5d%c ", svalue[sq],(color[sq] == white)?'b':'w');}
  754.       else
  755.         printz("    *  ");
  756.     }
  757.       printz("\n");
  758.     }
  759.     printz("stage = %d\n",stage);
  760.   printz (CP[103], score, 
  761.              mtl[computer], pscore[computer], GameType[computer],
  762.              mtl[opponent], pscore[opponent], GameType[opponent]);
  763. }
  764.  
  765. void
  766. DoTable (short table[NO_SQUARES])
  767. {
  768.   short  sq,j,k;
  769.   ExaminePosition ();
  770.   for(j=(NO_ROWS-1);j>=0;j--){
  771.   for(k=0;k<NO_COLS;k++){
  772.     sq=j*(NO_ROWS)+k;
  773.     printz ("%3d ", table[sq]);
  774.   }
  775. printz("\n");
  776. }
  777. }
  778.  
  779. void
  780. ShowPostnValues (void)
  781. {
  782.   short sq, score,j,k;
  783.   ExaminePosition ();
  784.   for(j=(NO_ROWS-1);j>=0;j--){
  785.   for(k=0;k<NO_COLS;k++){
  786.   sq=j*NO_COLS+k;
  787.     ShowPostnValue (sq);
  788.   }
  789.     printz("\n");
  790.   }
  791.   score = ScorePosition (opponent);
  792.  printz (CP[103], score, 
  793.            mtl[computer], pscore[computer], GameType[computer],
  794.            mtl[opponent], pscore[opponent], GameType[opponent]);
  795.  printz("\nhung black %d hung white %d\n",hung[black],hung[white]);
  796. }
  797.  
  798.