Finally get rid of that highly non-standard use of SIGINT.
[gnushogi.git] / gnushogi / rawdsp.c
1 /*
2  * FILE: rawdsp.c
3  *
4  * ----------------------------------------------------------------------
5  * Copyright (c) 1993, 1994, 1995 Matthias Mutz
6  * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
7  *
8  * GNU SHOGI is based on GNU CHESS
9  *
10  * Copyright (c) 1988, 1989, 1990 John Stanback
11  * Copyright (c) 1992 Free Software Foundation
12  *
13  * This file is part of GNU SHOGI.
14  *
15  * GNU Shogi is free software; you can redistribute it and/or modify it
16  * under the terms of the GNU General Public License as published by the
17  * Free Software Foundation; either version 3 of the License,
18  * or (at your option) any later version.
19  *
20  * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
21  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23  * for more details.
24  *
25  * You should have received a copy of the GNU General Public License along
26  * with GNU Shogi; see the file COPYING. If not, see
27  * <http://www.gnu.org/licenses/>.
28  * ----------------------------------------------------------------------
29  *
30  */
31
32 #include <ctype.h>
33 #include <signal.h>
34 #include <sys/param.h>
35 #include <sys/types.h>
36 #include <sys/file.h>
37
38 #include "gnushogi.h"
39 #include "rawdsp.h"
40
41 unsigned short MV[MAXDEPTH];
42 int MSCORE;
43
44 int mycnt1, mycnt2;
45 char *DRAW;
46 extern char *InPtr;
47 extern short pscore[];
48
49
50 /****************************************
51  * Trivial output functions.
52  ****************************************/
53
54 void
55 Raw_ClearScreen(void)
56 {
57     if (!barebones && !XSHOGI)
58         printf("\n");
59 }
60
61
62 /* FIXME: change to ShowPrompt? */
63 void
64 PromptForMove(void)
65 {
66     if (!barebones && !XSHOGI)
67     {
68         /* printf("\nYour move is? "); */
69         fputs(CP[124], stdout);
70     }
71 }
72
73
74 void
75 Raw_ShowCurrentMove(short pnt, short f, short t)
76 {
77 }
78
79
80 void
81 Raw_ShowDepth(char ch)
82 {
83     if (!barebones && !XSHOGI)
84     {
85         printf(CP[53], Sdepth, ch);   /* Depth = %d%c */
86         printf("\n");
87     }
88 }
89
90
91 void
92 Raw_ShowGameType(void)
93 {
94     if (flag.post)
95         printf("%c vs. %c\n", GameType[black], GameType[white]);
96 }
97
98
99 void
100 Raw_ShowLine(unsigned short *bstline)
101 {
102     int i;
103
104     for (i = 1; bstline[i] > 0; i++)
105     {
106         if ((i > 1) && (i % 8 == 1))
107             printf("\n                          ");
108
109         algbr((short)(bstline[i] >> 8), (short)(bstline[i] & 0xFF), false);
110         printf("%5s ", mvstr[0]);
111     }
112
113     printf("\n");
114 }
115
116
117 void
118 Raw_ShowMessage(char *s)
119 {
120     if (!XSHOGI)
121         printf("%s\n", s);
122 }
123
124
125 void
126 Raw_ShowPatternCount(short side, short n)
127 {
128     if (flag.post)
129         printf("%s matches %d pattern(s)\n", ColorStr[side], n);
130 }
131
132
133 void
134 Raw_ShowResponseTime(void)
135 {
136 }
137
138
139 void
140 Raw_ShowResults(short score, unsigned short *bstline, char ch)
141 {
142     if (flag.post  && !XSHOGI)
143     {
144         ElapsedTime(2);
145         printf("%2d%c %6d %4ld %8ld  ",
146                Sdepth, ch, score, et / 100, NodeCnt);
147         Raw_ShowLine(bstline);
148     }
149 }
150
151
152 void
153 Raw_ShowSidetoMove(void)
154 {
155 }
156
157
158 void
159 Raw_ShowStage(void)
160 {
161     printf("stage = %d\n", stage);
162     printf("balance[black] = %d balance[white] = %d\n",
163            balance[black], balance[white]);
164 }
165
166 /****************************************
167  * End of trivial output routines.
168  ****************************************/
169
170
171 void
172 Raw_Initialize(void)
173 {
174     mycnt1 = mycnt2 = 0;
175
176     if (XSHOGI)
177     {
178 #ifdef HAVE_SETLINEBUF
179         setlinebuf(stdout);
180 #else
181 #  ifdef HAVE_SETVBUF
182         setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
183 #  else
184 #    error "Need setlinebuf() or setvbuf() to compile gnushogi!"
185 #  endif
186 #endif
187         printf("GNU Shogi %sp%s\n", version, patchlevel);
188     }
189
190     if (hard_time_limit)
191     {
192         if (!TCflag && (MaxResponseTime == 0))
193             MaxResponseTime = 15L * 100L;
194     }
195 }
196
197
198
199 void
200 Raw_ExitShogi(void)
201 {
202     /* CHECKME: what purpose does this next statement serve? */
203     signal(SIGTERM, SIG_IGN);
204
205     if (!nolist)
206         ListGame();
207
208     exit(0);
209 }
210
211
212 void
213 Raw_Die(int sig)
214 {
215     char s[80];
216
217     Raw_ShowMessage(CP[31]);        /* Abort? */
218     scanf("%s", s);
219
220     if (strcmp(s, CP[210]) == 0)    /* yes */
221         Raw_ExitShogi();
222 }
223
224
225
226 void
227 Raw_TerminateSearch(int sig)
228 {
229 #ifdef INTERRUPT_TEST
230     ElapsedTime(INIT_INTERRUPT_MODE);
231 #endif
232
233     if (!flag.timeout)
234         flag.back = true; /* previous: flag.timeout = true; */
235
236     flag.bothsides = false;
237 }
238
239
240
241 void
242 Raw_help(void)
243 {
244     Raw_ClearScreen();
245     /* printf("SHOGI command summary\n"); */
246     printf(CP[40], version, patchlevel);
247     printf("----------------------------------"
248            "------------------------------\n");
249     /* printf("7g7f      move from 7g to 7f      quit
250      * Exit Shogi\n"); */
251     fputs(CP[158], stdout);
252     /* printf("S6h       move silver to 6h       beep
253      * turn %s\n", (flag.beep) ? "off" : "on"); */
254     printf(CP[86], (flag.beep) ? CP[92] : CP[93]);
255     /* printf("2d2c+     move from 2d to 2c and promote\n"); */
256     printf(CP[128], (flag.material) ? CP[92] : CP[93]);
257     /* printf("P*5e      drop pawn to 5e         easy
258      * turn %s\n", (flag.easy) ? "off" : "on"); */
259     printf(CP[173], (flag.easy) ? CP[92] : CP[93]);
260     /* printf("                                  hash
261      * turn %s\n", (flag.hash) ? "off" : "on"); */
262     printf(CP[174], (flag.hash) ? CP[92] : CP[93]);
263     /* printf("bd        redraw board            reverse
264      * board display\n"); */
265     fputs(CP[130], stdout);
266     /* printf("list      game to shogi.lst       book
267      * turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount); */
268     printf(CP[170], (Book) ? CP[92] : CP[93], bookcount, booksize);
269     /* printf("undo      undo last ply           remove
270      * take back a move\n"); */
271     fputs(CP[200], stdout);
272     /* printf("edit      edit board              force
273      * enter game moves\n"); */
274     fputs(CP[153], stdout);
275     /* printf("switch    sides with computer     both
276      * computer match\n"); */
277     fputs(CP[194], stdout);
278     /* printf("black     computer plays black    white
279      * computer plays white\n"); */
280     fputs(CP[202], stdout);
281     /* printf("depth     set search depth        clock
282      * set time control\n"); */
283     fputs(CP[149], stdout);
284     /* printf("post      principle variation     hint
285      * suggest a move\n"); */
286     fputs(CP[177], stdout);
287     /* printf("save      game to file            get
288      * game from file\n"); */
289     fputs(CP[188], stdout);
290     printf("xsave     pos. to xshogi file     xget"
291            "      pos. from xshogi file\n");
292     /* printf("random    randomize play          new
293      * start new game\n"); */
294     fputs(CP[181], stdout);
295     printf("--------------------------------"
296            "--------------------------------\n");
297     /* printf("Computer: %-12s Opponent:            %s\n", */
298     printf(CP[46],
299            ColorStr[computer], ColorStr[opponent]);
300     /* printf("Depth:    %-12d Response time:       %d sec\n", */
301     printf(CP[51],
302            MaxSearchDepth, MaxResponseTime/100);
303     /* printf("Random:   %-12s Easy mode:           %s\n", */
304     printf(CP[99],
305            (dither) ? CP[93] : CP[92], (flag.easy) ? CP[93] : CP[92]);
306     /* printf("Beep:     %-12s Transposition file: %s\n", */
307     printf(CP[36],
308            (flag.beep) ? CP[93] : CP[92], (flag.hash) ? CP[93] : CP[92]);
309     /* printf("Tsume:    %-12s Force:               %s\n")*/
310     printf(CP[232],
311            (flag.tsume) ? CP[93] : CP[92], (flag.force) ? CP[93] : CP[92]);
312     /* printf("Time Control %s %d moves %d seconds %d opr %d
313      * depth\n", (TCflag) ? "ON" : "OFF", */
314     printf(CP[110],
315            (TCflag) ? CP[93] : CP[92],
316            TimeControl.moves[black], TimeControl.clock[black] / 100,
317            TCadd/100, MaxSearchDepth);
318 }
319
320
321
322 /*
323  * Set up a board position. Pieces are entered by typing the piece followed
324  * by the location. For example, Nf3 will place a knight on square f3.
325  */
326
327 void
328 Raw_EditBoard(void)
329 {
330     short a, r, c, sq, i, found;
331     char s[80];
332
333     flag.regularstart = true;
334     Book = BOOKFAIL;
335     Raw_ClearScreen();
336     Raw_UpdateDisplay(0, 0, 1, 0);
337     /* printf(".   exit to main\n"); */
338     fputs(CP[29], stdout);
339     /* printf("#   clear board\n"); */
340     fputs(CP[28], stdout);
341     /* printf("c   change sides\n"); */
342     fputs(CP[136], stdout);
343     /* printf("enter piece & location: \n"); */
344     fputs(CP[155], stdout);
345
346     a = black;
347
348     do
349     {
350         scanf("%s", s);
351         found = 0;
352
353         if (s[0] == CP[28][0])  /*#*/
354         {
355             for (sq = 0; sq < NO_SQUARES; sq++)
356             {
357                 board[sq] = no_piece;
358                 color[sq] = neutral;
359             }
360
361             ClearCaptured();
362         }
363
364         if (s[0] == CP[136][0]) /*c*/
365             a = otherside[a];
366
367         if (s[1] == '*')
368         {
369             for (i = pawn; i <= king; i++)
370             {
371                 if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
372                 {
373                     Captured[a][i]++;
374                     found = 1;
375                     break;
376                 }
377             }
378
379             c = -1;
380             r = -1;
381         }
382         else
383         {
384             c = COL_NAME(s[1]);
385             r = ROW_NAME(s[2]);
386         }
387
388         if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
389         {
390             sq = locn(r, c);
391             color[sq] = a;
392             board[sq] = no_piece;
393
394             for (i = no_piece; i <= king; i++)
395             {
396                 if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
397                 {
398                     if (s[3] == '+')
399                         board[sq] = promoted[i];
400                     else
401                         board[sq] = i;
402
403                     found = 1;
404                     break;
405                 }
406             }
407
408             if (found == 0)
409                 color[sq] = neutral;
410         }
411     }
412     while (s[0] != CP[29][0]);
413
414     for (sq = 0; sq < NO_SQUARES; sq++)
415         Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
416
417     GameCnt = 0;
418     Game50 = 1;
419     ZeroRPT();
420     Sdepth = 0;
421     InitializeStats();
422     Raw_ClearScreen();
423     Raw_UpdateDisplay(0, 0, 1, 0);
424 }
425
426
427
428
429 /*
430  * Set up a board position.
431  * Nine lines of nine characters are used to setup the board. 9a-1a is the
432  * first line. White pieces are  represented  by  uppercase characters.
433  */
434
435 void
436 SetupBoard(void)
437 {
438     short r, c, sq, i;
439     char ch;
440     char s[80];
441
442     NewGame();
443
444     fgets(s, 80, stdin);            /* skip "setup" command */
445
446     for (r = NO_ROWS - 1; r >= 0; r--)
447     {
448         fgets(s, 80, stdin);
449
450         for (c = 0; c <= (NO_COLS - 1); c++)
451         {
452             ch = s[c];
453             sq = locn(r, c);
454             color[sq] = neutral;
455             board[sq] = no_piece;
456
457             for (i = no_piece; i <= king; i++)
458             {
459                 if (ch == pxx[i])
460                 {
461                     color[sq] = white;
462                     board[sq] = i;
463                     break;
464                 }
465                 else if (ch == qxx[i])
466                 {
467                     color[sq] = black;
468                     board[sq] = i;
469                     break;
470                 }
471             }
472         }
473     }
474
475     for (sq = 0; sq < NO_SQUARES; sq++)
476         Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
477
478     InitializeStats();
479     Raw_ClearScreen();
480     Raw_UpdateDisplay(0, 0, 1, 0);
481     /* printf("Setup successful\n"); */
482     fputs(CP[106], stdout);
483 }
484
485
486 void
487 Raw_SearchStartStuff(short side)
488 {
489     if (flag.post)
490     {
491         printf(CP[123],
492                GameCnt/2 + 1,
493                ResponseTime, TimeControl.clock[side]);
494     }
495 }
496
497
498
499 void
500 Raw_OutputMove(void)
501 {
502     if (flag.illegal)
503     {
504         printf("%s\n", CP[225]);
505         return;
506     }
507
508     if (mvstr[0][0] == '\0')
509         goto nomove;
510
511     if (XSHOGI)
512     {
513         /* add remaining time in milliseconds to xshogi */
514         printf("%d. ... %s %ld\n", ++mycnt1, mvstr[0],
515                (TimeControl.clock[player] - et) * 10);
516     }
517     else
518     {
519         printf("%d. ... %s\n", ++mycnt1, mvstr[0]);
520     }
521
522  nomove:
523     if ((root->flags & draw) || (root->score == -(SCORE_LIMIT + 999))
524         || (root->score == (SCORE_LIMIT + 998)))
525         goto summary;
526
527     if (flag.post)
528     {
529         short h, l, t;
530
531         h = TREE;
532         l = 0;
533         t = TREE >> 1;
534
535         while (l != t)
536         {
537             if (Tree[t].f || Tree[t].t)
538                 l = t;
539             else
540                 h = t;
541
542             t = (l + h) >> 1;
543         }
544
545         /* printf("Nodes %ld Tree %d Eval %ld
546          * Rate %ld RS high %ld low %ld\n", */
547         printf(CP[89], GenCnt, NodeCnt, t, EvalNodes,
548                (et > 100) ? (NodeCnt / (et / 100)) : 0,
549                EADD, EGET, reminus, replus);
550
551         /* printf("Hin/Hout/Coll/Fin/Fout =
552          * %ld/%ld/%ld/%ld/%ld\n", */
553         printf(CP[71],
554                HashAdd, HashCnt, THashCol, HashCol, FHashCnt, FHashAdd);
555     }
556
557     Raw_UpdateDisplay(root->f, root->t, 0, root->flags);
558
559     if (!XSHOGI)
560     {
561         /* printf("My move is: %s\n", mvstr[0]); */
562         printf(CP[83], mvstr[0]);
563
564         if (flag.beep)
565             printf("%c", 7);
566     }
567
568  summary:
569     if (root->flags & draw)
570     {
571         /*  printf("Drawn game!\n"); */
572         fputs(CP[57], stdout);
573     }
574     else if (root->score == -(SCORE_LIMIT + 999))
575     {
576         printf("%s mates!\n", ColorStr[opponent]);
577     }
578     else if (root->score == (SCORE_LIMIT + 998))
579     {
580         printf("%s mates!\n", ColorStr[computer]);
581     }
582 #ifdef VERYBUGGY
583     else if (!barebones && (root->score < -SCORE_LIMIT))
584     {
585         printf("%s has a forced mate in %d moves!\n",
586                ColorStr[opponent], SCORE_LIMIT + 999 + root->score - 1);
587     }
588     else if (!barebones && (root->score > SCORE_LIMIT))
589     {
590         printf("%s has a forced mate in %d moves!\n",
591                ColorStr[computer], SCORE_LIMIT + 998 - root->score - 1);
592     }
593 #endif /* VERYBUGGY */
594 }
595
596
597 void
598 Raw_UpdateDisplay(short f, short t, short redraw, short isspec)
599 {
600
601     short r, c, l, m;
602
603     if (redraw && !XSHOGI)
604     {
605         printf("\n");
606         r = (short)(TimeControl.clock[black] / 6000);
607         c = (short)((TimeControl.clock[black] % 6000) / 100);
608         l = (short)(TimeControl.clock[white] / 6000);
609         m = (short)((TimeControl.clock[white] % 6000) / 100);
610         /* printf("Black %d:%02d  White %d:%02d\n", r, c, l, m); */
611         printf(CP[116], r, c, l, m);
612         printf("\n");
613
614         for (r = (NO_ROWS - 1); r >= 0; r--)
615         {
616             for (c = 0; c <= (NO_COLS - 1); c++)
617             {
618                 char pc;
619                 l = ((flag.reverse)
620                      ? locn((NO_ROWS - 1) - r, (NO_COLS - 1) - c)
621                      : locn(r, c));
622                 pc = (is_promoted[board[l]] ? '+' : ' ');
623
624                 if (color[l] == neutral)
625                     printf(" -");
626                 else if (color[l] == black)
627                     printf("%c%c", pc, qxx[board[l]]);
628                 else
629                     printf("%c%c", pc, pxx[board[l]]);
630             }
631
632             printf("\n");
633         }
634
635         printf("\n");
636         {
637             short side;
638
639             for (side = black; side <= white; side++)
640             {
641                 short piece, c;
642                 printf((side == black)?"black ":"white ");
643
644                 for (piece = pawn; piece <= king; piece++)
645                 {
646                     if ((c = Captured[side][piece]))
647                         printf("%i%c ", c, pxx[piece]);
648                 }
649
650                 printf("\n");
651             }
652         }
653     }
654 }
655
656
657
658 void
659 Raw_ChangeAlphaWindow(void)
660 {
661     printf("WAwindow: ");
662     scanf("%hd", &WAwindow);
663     printf("BAwindow: ");
664     scanf("%hd", &BAwindow);
665 }
666
667
668
669 void
670 Raw_ChangeBetaWindow(void)
671 {
672     printf("WBwindow: ");
673     scanf("%hd", &WBwindow);
674     printf("BBwindow: ");
675     scanf("%hd", &BBwindow);
676 }
677
678
679
680 void
681 Raw_GiveHint(void)
682 {
683     if (hint)
684     {
685         algbr((short) (hint >> 8), (short) (hint & 0xFF), false);
686         printf(CP[72], mvstr[0]);   /*hint*/
687     }
688     else
689         fputs(CP[223], stdout);
690 }
691
692
693
694 void
695 Raw_SelectLevel(char *sx)
696 {
697
698     char T[NO_SQUARES + 1], *p, *q;
699
700     if ((p = strstr(sx, CP[169])) != NULL)
701         p += strlen(CP[169]);
702     else if ((p = strstr(sx, CP[217])) != NULL)
703         p += strlen(CP[217]);
704
705     strcat(sx, "XX");
706     q = T;
707     *q = '\0';
708
709     for (; *p != 'X'; *q++ = *p++);
710
711     *q = '\0';
712
713     /* line empty ask for input */
714     if (!T[0])
715     {
716         fputs(CP[61], stdout);
717         fgets(T, NO_SQUARES + 1, stdin);
718         strcat(T, "XX");
719     }
720
721     /* skip blackspace */
722     for (p = T; *p == ' '; p++) ;
723
724     /* could be moves or a fischer clock */
725     if (*p == 'f')
726     {
727         /* its a fischer clock game */
728         p++;
729         TCminutes = (short)strtol(p, &q, 10);
730         TCadd = (short)strtol(q, NULL, 10) *100;
731         TCseconds = 0;
732         TCmoves = 50;
733     }
734     else
735     {
736         /* regular game */
737         TCadd = 0;
738         TCmoves = (short)strtol(p, &q, 10);
739         TCminutes = (short)strtol(q, &q, 10);
740
741         if (*q == ':')
742             TCseconds = (short)strtol(q + 1, (char **) NULL, 10);
743         else
744             TCseconds = 0;
745
746 #ifdef OPERATORTIME
747         fputs(CP[94], stdout);
748         scanf("%hd", &OperatorTime);
749 #endif
750
751         if (TCmoves == 0)
752         {
753             TCflag = false;
754             MaxResponseTime = TCminutes*60L * 100L + TCseconds * 100L;
755             TCminutes = TCseconds = 0;
756         }
757         else
758         {
759             TCflag = true;
760             MaxResponseTime = 0;
761         }
762     }
763
764     TimeControl.clock[black] = TimeControl.clock[white] = 0;
765     SetTimeControl();
766
767     if (XSHOGI)
768     {
769         printf("Clocks: %ld %ld\n",
770                TimeControl.clock[black] * 10,
771                TimeControl.clock[white] * 10);
772     }
773 }
774
775
776
777
778 void
779 Raw_ChangeSearchDepth(void)
780 {
781     printf("depth = ");
782     scanf("%hd", &MaxSearchDepth);
783     TCflag = !(MaxSearchDepth > 0);
784 }
785
786
787
788
789 void
790 Raw_ChangeHashDepth(void)
791 {
792     printf("hashdepth = ");
793     scanf("%hd", &HashDepth);
794     printf("MoveLimit = ");
795     scanf("%hd", &HashMoveLimit);
796 }
797
798
799
800 void
801 Raw_SetContempt(void)
802 {
803     printf("contempt = ");
804     scanf("%hd", &contempt);
805 }
806
807
808
809 void
810 Raw_ChangeXwindow(void)
811 {
812     printf("xwndw = ");
813     scanf("%hd", &xwndw);
814 }
815
816
817 /*
818  * Raw_ShowPostnValue(short sq)
819  * must have called ExaminePosition() first
820  */
821
822 void
823 Raw_ShowPostnValue(short sq)
824 {
825     short score;
826     score = ScorePosition(color[sq]);
827
828     if (color[sq] != neutral)
829     {
830 #if defined SAVE_SVALUE
831         printf("???%c ", (color[sq] == white)?'b':'w');
832 #else
833         printf("%3d%c ", svalue[sq], (color[sq] == white)?'b':'w');
834 #endif
835     }
836     else
837     {
838         printf(" *   ");
839     }
840 }
841
842
843
844 void
845 Raw_DoDebug(void)
846 {
847     short c, p, sq, tp, tc, tsq, score, j, k;
848     char s[40];
849
850     ExaminePosition(opponent);
851     Raw_ShowMessage(CP[65]);
852     scanf("%s", s);
853     c = neutral;
854
855     if ((s[0] == CP[9][0]) || (s[0] == CP[9][1]))    /* w W */
856         c = black;
857
858     if ((s[0] == CP[9][2]) || (s[0] == CP[9][3]))    /* b B */
859         c = white;
860
861     for (p = king; p > no_piece; p--)
862     {
863         if ((s[1] == pxx[p]) || (s[1] == qxx[p]))
864             break;
865     }
866
867     if (p > no_piece)
868     {
869         for (j = (NO_ROWS - 1); j >= 0; j--)
870         {
871             for (k = 0; k < (NO_COLS); k++)
872             {
873                 sq = j*(NO_COLS) + k;
874                 tp = board[sq];
875                 tc = color[sq];
876                 board[sq] = p;
877                 color[sq] = c;
878                 tsq = PieceList[c][1];
879                 PieceList[c][1] = sq;
880                 Raw_ShowPostnValue(sq);
881                 PieceList[c][1] = tsq;
882                 board[sq] = tp;
883                 color[sq] = tc;
884             }
885
886             printf("\n");
887         }
888     }
889
890     score = ScorePosition(opponent);
891
892     for (j = (NO_ROWS - 1); j >= 0; j--)
893     {
894         for (k = 0; k < (NO_COLS); k++)
895         {
896             sq = j*(NO_COLS) + k;
897
898             if (color[sq] != neutral)
899             {
900 #if defined SAVE_SVALUE
901                 printf("%?????%c ", (color[sq] == white)?'b':'w');
902 #else
903                 printf("%5d%c ", svalue[sq], (color[sq] == white)?'b':'w');
904 #endif
905             }
906             else
907             {
908                 printf("    *  ");
909             }
910         }
911
912         printf("\n");
913     }
914
915     printf("stage = %d\n", stage);
916     printf(CP[103], score,
917            mtl[computer], pscore[computer], GameType[computer],
918            mtl[opponent], pscore[opponent], GameType[opponent]);
919 }
920
921
922
923 void
924 Raw_DoTable(short table[NO_SQUARES])
925 {
926     short  sq, j, k;
927     ExaminePosition(opponent);
928
929     for (j = (NO_ROWS - 1); j >= 0; j--)
930     {
931         for (k = 0; k < NO_COLS; k++)
932         {
933             sq = j*(NO_ROWS) + k;
934             printf("%3d ", table[sq]);
935         }
936
937         printf("\n");
938     }
939 }
940
941
942
943 void
944 Raw_ShowPostnValues(void)
945 {
946     short sq, score, j, k;
947     ExaminePosition(opponent);
948
949     for (j = (NO_ROWS - 1); j >= 0; j--)
950     {
951         for (k = 0; k < NO_COLS; k++)
952         {
953             sq = j * NO_COLS + k;
954             Raw_ShowPostnValue(sq);
955         }
956
957         printf("\n");
958     }
959
960     score = ScorePosition(opponent);
961     printf(CP[103], score,
962            mtl[computer], pscore[computer], GameType[computer],
963            mtl[opponent], pscore[opponent], GameType[opponent]);
964     printf("\nhung black %d hung white %d\n", hung[black], hung[white]);
965 }