Initial commit based on GNU Shogi 1.2 patchlevel 3.
[gnushogi.git] / src / uxdsp.c
blob4afeb1b6bb4a0a622764720151bf46b6210f68c8
1 /*
2 * uxdsp.c - ALPHA interface for GNU SHOGI
4 * Copyright (c) 1993, 1994, 1995 Matthias Mutz
6 * GNU SHOGI is based on GNU CHESS
8 * Copyright (c) 1988,1989,1990 John Stanback
9 * Copyright (c) 1992 Free Software Foundation
11 * This file is part of GNU SHOGI.
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.
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.
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.
28 #include <ctype.h>
29 #include <signal.h>
31 #if defined MSDOS
32 #include <dos.h>
33 #include <conio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <time.h>
38 #define ESC 0x1B
39 #define refresh() fflush(stdout)
41 static void param (short n);
43 #elif defined THINK_C
45 #include <stdio.h>
46 #include <console.h>
48 #define clear() cgotoxy(1,1,stdout),ccleos(stdout)
49 #define refresh() fflush(stdout)
51 #else
53 #include <sys/param.h>
54 #include <sys/types.h>
55 #include <sys/file.h>
56 #include <curses.h>
58 #endif /* MSDOS */
60 #include "gnushogi.h"
62 int mycnt1, mycnt2;
64 #define TAB (58)
66 #define VIR_C(s) ((flag.reverse) ? 8-column(s) : column(s))
67 #define VIR_R(s) ((flag.reverse) ? 8-row(s) : row(s))
69 unsigned short int MV[MAXDEPTH];
70 int MSCORE;
71 char *DRAW;
73 void TerminateSearch (int), Die (int);
75 void
76 Initialize (void)
78 signal (SIGINT, Die);
79 #if !defined MSDOS && !defined THINK_C
80 signal (SIGQUIT, Die);
81 initscr ();
82 crmode ();
83 #else
84 mycnt1 = mycnt2 = 0;
85 #endif /* MSDOS */
88 void
89 ExitChess (void)
91 #ifndef NOLIST
92 ListGame ();
93 #endif
94 gotoXY (1, 24);
95 #if !defined MSDOS && !defined THINK_C
96 refresh();
97 nocrmode ();
98 endwin ();
99 #endif /* MSDOS */
100 exit (0);
103 void
104 Die (int Sig)
106 char s[80];
108 signal (SIGINT, SIG_IGN);
109 #if defined MSDOS || defined THINK_C
110 Sig++; /* shut up the compiler */
111 #else
112 signal (SIGQUIT, SIG_IGN);
113 #endif /* MSDOS */
114 ShowMessage (CP[31]); /*Abort?*/
115 scanz ("%s", s);
116 if (strcmp (s, CP[210]) == 0) /*yes*/
117 ExitChess ();
118 signal (SIGINT, Die);
119 #if !defined MSDOS && !defined THINK_C
120 signal (SIGQUIT, Die);
121 #endif /* MSDOS */
124 void
125 TerminateSearch (int Sig)
127 signal (SIGINT, SIG_IGN);
128 #if defined MSDOS || defined THINK_C
129 Sig++; /* shut up the compiler */
130 #else
131 signal (SIGQUIT, SIG_IGN);
132 #endif /* MSDOS */
133 if (!flag.timeout)
134 flag.musttimeout = true;
135 ShowMessage("Terminate Search");
136 flag.bothsides = false;
137 signal (SIGINT, Die);
138 #if !defined MSDOS && !defined THINK_C
139 signal (SIGQUIT, Die);
140 #endif /* MSDOS */
142 void
143 ShowLine (short unsigned int *bstline)
147 void
148 help (void)
150 ClrScreen ();
151 /*printz ("GNU Shogi ??p? command summary\n");*/
152 printz (CP[40], version, patchlevel);
153 printz ("----------------------------------------------------------------\n");
154 /*printz ("7g7f move from 7g to 7f quit Exit Chess\n");*/
155 printz (CP[158]);
156 /*printz ("S6h move silver to 6h beep turn %s\n", (flag.beep) ? "off" : "on");*/
157 printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
158 /*printz ("2d2c+ move to 2c and promote\n");*/
159 printz (CP[128], (flag.material) ? CP[92] : CP[93]);
160 /*printz ("P*5e drop a pawn to 5e easy turn %s\n", (flag.easy) ? "off" : "on");*/
161 printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
162 /*printz (" hash turn %s\n", (flag.hash) ? "off" : "on");*/
163 printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
164 /*printz ("bd redraw board reverse board display\n");*/
165 printz (CP[130]);
166 /*printz ("list game to shogi.lst book turn %s used %d of %d\n", (Book) ? "off" : "on", book
167 count, booksize);*/
168 printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
169 /*printz ("undo undo last ply remove take back a move\n");*/
170 printz (CP[200]);
171 /*printz ("edit edit board force enter game moves\n");*/
172 printz (CP[153]);
173 /*printz ("switch sides with computer both computer match\n");*/
174 printz (CP[194]);
175 /*printz ("black computer plays black white computer plays white\n");*/
176 printz (CP[202]);
177 /*printz ("depth set search depth clock set time control\n");*/
178 printz (CP[149]);
179 /*printz ("hint suggest a move post turn %s principle variation\n", (flag.post) ? "off" :
180 "on");*/
181 printz (CP[177], (flag.post) ? CP[92] : CP[93]);
182 /*printz ("save game to file get game from file\n");*/
183 printz (CP[188]);
184 /*printz ("random randomize play new start new game\n");*/
185 printz (CP[181]);
186 gotoXY (10, 20);
187 printz (CP[47], ColorStr[computer]);
188 gotoXY (10, 21);
189 printz (CP[97], ColorStr[opponent]);
190 gotoXY (10, 22);
191 printz (CP[79], MaxResponseTime/100);
192 gotoXY (10, 23);
193 printz (CP[59], (flag.easy) ? CP[93] : CP[92]);
194 gotoXY (25, 23);
195 printz (CP[231], (flag.tsume) ? CP[93] : CP[92]);
196 gotoXY (40, 20);
197 printz (CP[52], MaxSearchDepth);
198 gotoXY (40, 21);
199 printz (CP[100], (dither) ? CP[93] : CP[92]);
200 gotoXY (40, 22);
201 printz (CP[112], (flag.hash) ? CP[93] : CP[92]);
202 gotoXY (40, 23);
203 printz (CP[73]);
204 gotoXY (10, 24);
205 printz (CP[110], (TCflag) ? CP[93] : CP[92],
206 TimeControl.moves[black], TimeControl.clock[black] / 100, OperatorTime, MaxSearchDepth);
207 refresh ();
208 #ifdef BOGUS
209 fflush (stdin); /*what is this supposed to do??*/
210 #endif /*BOGUS*/
211 getchar ();
212 ClrScreen ();
213 UpdateDisplay (0, 0, 1, 0);
217 static const short x0[2] = {54, 2};
218 static const short y0[2] = {20, 4};
221 static
222 void
223 UpdateCatched ()
226 short side;
227 for ( side = black; side <= white; side++ )
229 short x, y, piece, cside, k;
230 cside = flag.reverse ? (side ^ 1) : side;
231 x = x0[cside];
232 y = y0[cside];
233 k = 0;
234 for ( piece = pawn; piece <= king; piece++ )
235 { short n;
236 if ( n = Captured[side][piece] )
237 { gotoXY(x,y);
238 printz("%i%c",n,pxx[piece]);
239 if ( cside == black ) y--; else y++;
241 else
242 k++;
244 while ( k )
245 { k--;
246 gotoXY(x,y);
247 printz(" ");
248 if ( cside == black ) y--; else y++;
251 refresh();
255 void
256 EditBoard (void)
259 * Set up a board position. Pieces are entered by typing the piece followed
260 * by the location. For example, N3f will place a knight on square 3f.
261 * P* will put a pawn to the captured pieces.
265 short a, r, c, sq, i;
266 char s[80];
268 flag.regularstart = true;
269 Book = BOOKFAIL;
270 ClrScreen ();
271 UpdateDisplay (0, 0, 1, 0);
272 gotoXY (TAB, 3);
273 printz (CP[29]);
274 gotoXY (TAB, 4);
275 printz (CP[28]);
276 gotoXY (TAB, 5);
277 printz (CP[136]);
278 gotoXY (TAB, 7);
279 printz (CP[64]);
280 a = black;
283 gotoXY (TAB, 6);
284 printz (CP[60], ColorStr[a]); /*Editing %s*/
285 gotoXY (TAB + 24, 7);
286 ClrEoln ();
287 scanz ("%s", s);
288 if (s[0] == CP[28][0]) /*#*/
290 for (sq = 0; sq < NO_SQUARES; sq++)
292 board[sq] = no_piece;
293 color[sq] = neutral;
294 DrawPiece (sq);
296 ClearCaptured ();
297 UpdateCatched ();
299 if (s[0] == CP[136][0]) /*c*/
300 a = otherside[a];
301 if (s[1] == '*')
303 for (i = NO_PIECES; i > no_piece; i--)
304 if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
305 break;
306 Captured[a][unpromoted[i]]++;
307 UpdateCatched ();
308 c = -1;
310 else
312 c = '9' - s[1];
313 r = 'i' - s[2];
315 if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
317 sq = locn (r, c);
318 for (i = NO_PIECES; i > no_piece; i--)
319 if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
320 break;
321 if ( s[3] == '+' )
322 i = promoted[i];
323 else
324 i = unpromoted[i];
325 board[sq] = i;
326 color[sq] = ((board[sq] == no_piece) ? neutral : a);
327 DrawPiece (sq);
329 } while (s[0] != CP[29][0]); /*.*/
331 for (sq = 0; sq < NO_SQUARES; sq++)
332 Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
333 GameCnt = 0;
334 Game50 = 1;
335 ZeroRPT ();
336 Sdepth = 0;
337 InitializeStats ();
338 ClrScreen ();
339 UpdateDisplay (0, 0, 1, 0);
342 void
343 ShowPlayers (void)
345 gotoXY (5, ((flag.reverse) ? 23 : 2));
346 printz ("%s", (computer == white) ? CP[218] : CP[74]);
347 gotoXY (5, ((flag.reverse) ? 2 : 23));
348 printz ("%s", (computer == black) ? CP[218] : CP[74]);
351 void
352 ShowDepth (char ch)
354 gotoXY (TAB, 4);
355 printz ("Depth= %2d%c", Sdepth, ch); /*Depth= %d%c*/
356 ClrEoln ();
359 void
360 ShowStage (void)
362 gotoXY (TAB, 19);
363 printz("Stage= %2d%c B= %2d W= %2d",
364 stage,flag.tsume?'T':' ',balance[black],balance[white]);
365 ClrEoln ();
368 void
369 ShowScore (short score)
371 gotoXY (TAB, 5);
372 printz (CP[104], score);
373 ClrEoln ();
376 void
377 ShowMessage (char *s)
379 gotoXY (TAB, 6);
380 printz ("%s", s);
381 ClrEoln ();
384 void
385 ClearMessage (void)
387 gotoXY (TAB, 6);
388 ClrEoln ();
391 void
392 ShowCurrentMove (short int pnt, short int f, short int t)
394 algbr (f, t, false);
395 gotoXY (TAB, 7);
396 printz ("(%2d) %5s ", pnt, mvstr[0]);
399 void
400 ShowHeader (void)
402 gotoXY (TAB, 2);
403 printz (CP[69], version, patchlevel);
406 void
407 ShowSidetoMove (void)
409 gotoXY (TAB, 14);
410 printz ("%2d: %s", 1 + GameCnt / 2, ColorStr[player]);
411 ClrEoln ();
414 void
415 ShowPrompt (void)
417 gotoXY (TAB, 17);
418 printz (CP[121]); /*Your move is?*/
419 ClrEoln ();
422 void
423 ShowNodeCnt (long int NodeCnt)
425 gotoXY (TAB, 22);
426 /* printz (CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0); */
427 printz ("n=%ld n/s=%ld", NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
428 ClrEoln ();
431 void
432 ShowResults (short int score, short unsigned int *bstline, char ch)
434 unsigned char d, ply;
436 if (flag.post)
438 ShowDepth (ch);
439 ShowScore (score);
440 d = 7;
441 for (ply = 1; bstline[ply] > 0; ply++)
443 if (ply % 2 == 1)
445 gotoXY (TAB, ++d);
446 ClrEoln ();
448 algbr ((short) bstline[ply] >> 8, (short) bstline[ply] & 0xFF, false);
449 printz ("%5s ", mvstr[0]);
451 ClrEoln ();
452 while (d < 13)
454 gotoXY (TAB, ++d);
455 ClrEoln ();
460 void
461 ShowPatternCount (short side, short n)
463 if (flag.post)
465 gotoXY(TAB+10+3*side,20);
466 if ( n >= 0 )
467 printz("%3d",n);
468 else
469 printz(" ");
473 void
474 ShowGameType (void)
476 if (flag.post)
478 gotoXY(TAB,20);
479 printz("%c vs. %c",GameType[black],GameType[white]);
483 void
484 ShowResponseTime (void)
486 if (flag.post)
487 { short TCC=TCcount;
488 gotoXY(TAB,21);
489 /* printz("RT=%ld TCC=%d TCL=%ld EX=%ld ET=%ld TO=%d",
490 ResponseTime,TCC,TCleft,ExtraTime,et,flag.timeout); */
491 printz("%ld,%d,%ld,%ld,%ld,%d",
492 ResponseTime,TCC,TCleft,ExtraTime,et,flag.timeout);
493 ClrEoln ();
497 void
498 SearchStartStuff (short int side)
500 short i;
502 signal (SIGINT, TerminateSearch);
503 #if defined MSDOS || defined THINK_C
504 side++; /* shut up the compiler */
505 #else
506 signal (SIGQUIT, TerminateSearch);
507 #endif /* MSDOS */
508 for (i = 4; i < 14; i++)
510 gotoXY (TAB, i);
511 ClrEoln ();
515 void
516 OutputMove (void)
519 UpdateDisplay (root->f, root->t, 0, (short) root->flags);
520 gotoXY (TAB, 16);
521 if(flag.illegal){printz(CP[225]);return;}
522 printz (CP[84], mvstr[0]); /*My move is %s*/
523 if (flag.beep)
524 putchar (7);
525 ClrEoln ();
527 gotoXY (TAB, 18);
528 if (root->flags & draw)
529 printz (CP[58]);
530 else if (root->score == -(SCORE_LIMIT+999))
531 printz (CP[95]);
532 else if (root->score == SCORE_LIMIT+998)
533 printz (CP[44]);
534 #ifdef VERYBUGGY
535 else if (root->score < -SCORE_LIMIT)
536 printz (CP[96], SCORE_LIMIT+999 + root->score - 1);
537 else if (root->score > SCORE_LIMIT)
538 printz (CP[45], SCORE_LIMIT+998 - root->score - 1);
539 #endif /*VERYBUGGY*/
540 ClrEoln ();
541 if (flag.post)
543 register short h, l, t;
545 h = TREE;
546 l = 0;
547 t = TREE >> 1;
548 while (l != t)
550 if (Tree[t].f || Tree[t].t)
551 l = t;
552 else
553 h = t;
554 t = (l + h) >> 1;
557 ShowNodeCnt (NodeCnt);
558 gotoXY (TAB, 23);
559 printz (CP[81], t); /*Max Tree=*/
560 ClrEoln ();
562 ShowSidetoMove ();
565 void
566 UpdateClocks (void)
568 short m, s;
569 long dt;
571 if (TCflag)
573 m = (short) ((dt = (TimeControl.clock[player] - et)) / 6000);
574 s = (short) ((dt - 6000 * (long) m) / 100);
576 else
578 m = (short) ((dt = et) / 6000);
579 s = (short) (et - 6000 * (long) m) / 100;
581 if (m < 0)
582 m = 0;
583 if (s < 0)
584 s = 0;
585 if (player == black)
586 gotoXY (20, (flag.reverse) ? 2 : 23);
587 else
588 gotoXY (20, (flag.reverse) ? 23 : 2);
589 /* printz ("%d:%02d %ld ", m, s, dt); */
590 printz ("%d:%02d ", m, s);
591 if (flag.post)
592 ShowNodeCnt (NodeCnt);
593 refresh ();
596 void
597 gotoXY (short int x, short int y)
599 #if defined MSDOS
600 putchar (ESC);
601 putchar ('[');
602 param (y);
603 putchar (';');
604 param (x);
605 putchar ('H');
606 #elif defined THINK_C
607 cgotoxy (x, y, stdout);
608 #else
609 move (y - 1, x - 1);
610 #endif /* MSDOS */
613 void
614 ClrScreen (void)
616 #ifdef MSDOS
617 putchar (ESC);
618 putchar ('[');
619 putchar ('2');
620 putchar ('J');
621 #else
622 clear ();
623 #endif /* MSDOS */
624 refresh ();
627 void
628 ClrEoln (void)
630 #ifdef MSDOS
631 putchar (ESC);
632 putchar ('[');
633 putchar ('K');
634 #elif defined THINK_C
635 ccleol (stdout);
636 #else
637 clrtoeol ();
638 #endif /* MSDOS */
639 refresh ();
642 #ifdef MSDOS
643 void
644 param (short n)
646 if (n >= 10)
648 register short d, q;
650 q = n / 10;
651 d = n % 10;
652 putchar (q + '0');
653 putchar (d + '0');
655 else
656 putchar (n + '0');
659 #endif /* MSDOS */
661 void
662 DrawPiece (short int sq)
664 register char x, y;
666 char piece,l,r,p;
668 #if defined(MSDOS) && !defined(SEVENBIT)
669 if (color[sq] == white)
670 x = '7'; /* print WHITE boldface, */
671 else
672 x = '1'; /* print BLACK inverted */
673 piece = board[sq];
674 if ( is_promoted[piece] ) {
675 p = '+'; y = pxx[unpromoted[piece]];
676 } else {
677 p = ' '; y = pxx[piece];
679 gotoXY (8 + 5 * VIR_C (sq), 4 + 2 * (8 - VIR_R (sq)));
680 printz ("\033[%cm%c%c\033[0m", x, p, y);
681 #else
682 if ( color[sq]==neutral )
683 l = r = ' ';
684 else if ( flag.reverse ^ (color[sq]==black) ) {
685 l = '/'; r = '\\';
686 } else {
687 l = '\\', r = '/';
689 piece = board[sq];
690 if ( is_promoted[piece] ) {
691 p = '+'; y = pxx[unpromoted[piece]];
692 } else {
693 p = ' '; y = pxx[piece];
695 gotoXY (8 + 5 * VIR_C (sq), 4 + 2 * (8 - VIR_R (sq)));
696 printz ("%c%c%c%c", l, p, y, r);
697 #endif
700 void
701 ShowPostnValue (short int sq)
704 * must have called ExaminePosition() first
708 short score;
710 gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
711 score = ScorePosition (color[sq]);
712 if (color[sq] != neutral)
713 #if defined SAVE_SVALUE
714 printz ("??? ");
715 #else
716 printz ("%3d ", svalue[sq]);
717 #endif
718 else
719 printz (" ");
722 void
723 ShowPostnValues (void)
725 short sq, score;
727 ExaminePosition (opponent);
728 for (sq = 0; sq < NO_SQUARES; sq++)
729 ShowPostnValue (sq);
730 score = ScorePosition (opponent);
731 gotoXY (TAB, 5);
732 printz (CP[103], score,
733 mtl[computer], pscore[computer], GameType[computer],
734 mtl[opponent], pscore[opponent], GameType[opponent]);
736 ClrEoln ();
740 void
741 UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
743 short i, sq, z;
745 if (redraw)
747 ShowHeader ();
748 ShowPlayers ();
750 i = 2;
751 gotoXY (3, ++i);
752 #if defined(MSDOS) && !defined(SEVENBIT)
753 printz ("\332\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
754 "\302\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
755 "\302\304\304\304\304\302\304\304\304\304\277");
756 #else
757 printz (" +----+----+----+----+----+----+----+----+----+");
758 #endif /* MSDOS && !SEVENBIT */
759 while (i < 20)
761 gotoXY (1, ++i);
762 if (flag.reverse)
763 z = (i / 2) - 1;
764 else
765 z = 11 - ((i+1) / 2);
766 #if defined(MSDOS) && !defined(SEVENBIT)
767 printz ("%d \263 \263 \263 \263 \263 \263 " \
768 "\263 \263 \263", z);
769 #else
770 printz (" %c | | | | | | | | | |", 'a'+9-z);
771 #endif /* MSDOS && !SEVENBIT */
772 gotoXY (3, ++i);
773 if (i < 20)
774 #if defined(MSDOS) && !defined(SEVENBIT)
775 printz ("\303\304\304\304\304\305\304\304\304\304\305\304\304" \
776 "\304\304\305\304\304\304\304\305\304\304\304\304\305" \
777 "\304\304\304\304\305\304\304\304\304\305\304\304\304" \
778 "\304\264");
779 #else
780 printz (" +----+----+----+----+----+----+----+----+----+");
781 #endif /* MSDOS && !SEVENBIT */
783 #if defined(MSDOS) && !defined(SEVENBIT)
784 printz ("\300\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
785 "\301\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
786 "\301\304\304\304\304\301\304\304\304\304\331");
787 #else
788 printz (" +----+----+----+----+----+----+----+----+----+");
789 #endif /* MSDOS && !SEVENBIT */
790 gotoXY (3, 22);
791 printz(" ");
792 if (flag.reverse)
793 printz (CP[16]);
794 else
795 printz (CP[15]);
796 for (sq = 0; sq < NO_SQUARES; sq++)
797 DrawPiece (sq);
799 else /* not redraw */
801 if ( f < NO_SQUARES )
802 DrawPiece (f);
803 DrawPiece (t & 0x7f);
805 if ( (isspec & capture) || (isspec & dropmask) || redraw )
806 { short side;
807 for ( side = black; side <= white; side++ )
808 { short x, y, piece, cside, k;
809 cside = flag.reverse ? (side ^ 1) : side;
810 x = x0[cside];
811 y = y0[cside];
812 k = 0;
813 for ( piece = pawn; piece <= king; piece++ )
814 { short n;
815 if ( n = Captured[side][piece] )
816 { gotoXY(x,y);
817 printz("%i%c",n,pxx[piece]);
818 if ( cside == black ) y--; else y++;
820 else
821 k++;
823 while ( k )
824 { k--;
825 gotoXY(x,y);
826 printz(" ");
827 if ( cside == black ) y--; else y++;
831 refresh ();
834 extern char *InPtr;
836 void
837 ChangeAlphaWindow (void)
839 ShowMessage (CP[114]);
840 scanz ("%hd", &WAwindow);
841 ShowMessage (CP[34]);
842 scanz ("%hd", &BAwindow);
845 void
846 ChangeBetaWindow (void)
848 ShowMessage (CP[115]);
849 scanz ("%hd", &WBwindow);
850 ShowMessage (CP[35]);
851 scanz ("%hd", &BBwindow);
854 void
855 GiveHint (void)
857 char s[40];
858 if (hint)
860 algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
861 strcpy (s, CP[198]); /*try*/
862 strcat (s, mvstr[0]);
863 ShowMessage (s);
865 else
866 ShowMessage (CP[223]);
869 void
870 ChangeHashDepth (void)
872 ShowMessage (CP[163]);
873 scanz ("%hd", &HashDepth);
874 ShowMessage (CP[82]);
875 scanz ("%hd", &HashMoveLimit);
878 void
879 ChangeSearchDepth (void)
881 ShowMessage (CP[150]);
882 scanz ("%hd", &MaxSearchDepth);
883 TCflag = !(MaxSearchDepth > 0);
886 void
887 SetContempt (void)
889 ShowMessage (CP[142]);
890 scanz ("%hd", &contempt);
893 void
894 ChangeXwindow (void)
896 ShowMessage (CP[208]);
897 scanz ("%hd", &xwndw);
900 void
901 SelectLevel (char *sx)
903 int item;
905 ClrScreen ();
906 gotoXY (32, 2);
907 printz (CP[41], version, patchlevel);
908 gotoXY (20, 4);
909 printz (CP[18]);
910 gotoXY (20, 5);
911 printz (CP[19]);
912 gotoXY (20, 6);
913 printz (CP[20]);
914 gotoXY (20, 7);
915 printz (CP[21]);
916 gotoXY (20, 8);
917 printz (CP[22]);
918 gotoXY (20, 9);
919 printz (CP[23]);
920 gotoXY (20, 10);
921 printz (CP[24]);
922 gotoXY (20, 11);
923 printz (CP[25]);
924 gotoXY (20, 12);
925 printz (CP[26]);
926 gotoXY (20, 13);
927 printz (CP[27]);
929 OperatorTime = 0;
930 TCmoves = 40;
931 TCminutes = 5;
932 TCseconds = 0;
934 gotoXY (20, 17);
935 printz (CP[62]);
936 refresh ();
937 scanz ("%d", &item);
938 switch (item)
940 case 1:
941 TCmoves = 40;
942 TCminutes = 5;
943 break;
944 case 2:
945 TCmoves = 40;
946 TCminutes = 15;
947 break;
948 case 3:
949 TCmoves = 40;
950 TCminutes = 30;
951 break;
952 case 4:
953 TCmoves = 80;
954 TCminutes = 15;
955 flag.gamein = true;
956 break;
957 case 5:
958 TCmoves = 80;
959 TCminutes = 30;
960 flag.gamein = true;
961 break;
962 case 6:
963 TCmoves = 80;
964 TCminutes = 15;
965 TCadd = 3000;
966 flag.gamein = true;
967 break;
968 case 7:
969 TCmoves = 80;
970 TCminutes = 30;
971 TCadd = 3000;
972 break;
973 case 8:
974 TCmoves = 1;
975 TCminutes = 1;
976 flag.onemove = true;
977 break;
978 case 9:
979 TCmoves = 1;
980 TCminutes = 15;
981 flag.onemove = true;
982 break;
983 case 10:
984 TCmoves = 1;
985 TCminutes = 30;
986 flag.onemove = true;
987 break;
990 TCflag = (TCmoves > 0);
992 TimeControl.clock[black] = TimeControl.clock[white] = 0;
994 SetTimeControl ();
995 ClrScreen ();
996 UpdateDisplay (0, 0, 1, 0);
999 void
1000 DoDebug (void)
1002 short c, p, sq, tp, tc, tsq, score;
1003 char s[40];
1005 ExaminePosition (opponent);
1006 ShowMessage (CP[65]);
1007 scanz ("%s", s);
1008 c = neutral;
1009 if (s[0] == CP[9][0] || s[0] == CP[9][1]) /*b B*/
1010 c = black;
1011 if (s[0] == CP[9][2] || s[0] == CP[9][3]) /*w W*/
1012 c = white;
1013 for (p = king; p > no_piece; p--)
1014 if ((s[1] == pxx[p]) || (s[1] == qxx[p]))
1015 break;
1016 for (sq = 0; sq < NO_SQUARES; sq++)
1018 tp = board[sq];
1019 tc = color[sq];
1020 board[sq] = p;
1021 color[sq] = c;
1022 tsq = PieceList[c][1];
1023 PieceList[c][1] = sq;
1024 ShowPostnValue (sq);
1025 PieceList[c][1] = tsq;
1026 board[sq] = tp;
1027 color[sq] = tc;
1029 score = ScorePosition (opponent);
1030 gotoXY (TAB, 5);
1031 printz (CP[103], score,
1032 mtl[computer], pscore[computer], GameType[computer],
1033 mtl[opponent], pscore[opponent], GameType[opponent]);
1035 ClrEoln ();
1038 void
1039 DoTable (short table[NO_SQUARES])
1041 short sq;
1042 ExaminePosition (opponent);
1043 for (sq=0;sq<NO_SQUARES;sq++) {
1044 gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
1045 printz ("%3d ", table[sq]);