Restore SIGINT for stopping gnushogi when thinking.
[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
209
210 void
211 Raw_Die(int sig)
212 {
213     char s[80];
214
215     Raw_ShowMessage(CP[31]);        /* Abort? */
216     scanf("%s", s);
217
218     if (strcmp(s, CP[210]) == 0)    /* yes */
219         Raw_ExitShogi();
220 }
221
222
223
224 void
225 Raw_TerminateSearch(int sig)
226 {
227 #ifdef INTERRUPT_TEST
228     ElapsedTime(INIT_INTERRUPT_MODE);
229 #endif
230
231     if (!flag.timeout)
232         flag.back = true; /* previous: flag.timeout = true; */
233
234     flag.bothsides = false;
235 }
236
237
238
239 void
240 Raw_help(void)
241 {
242     Raw_ClearScreen();
243     /* printf("SHOGI command summary\n"); */
244     printf(CP[40], version, patchlevel);
245     printf("----------------------------------"
246            "------------------------------\n");
247     /* printf("7g7f      move from 7g to 7f      quit
248      * Exit Shogi\n"); */
249     fputs(CP[158], stdout);
250     /* printf("S6h       move silver to 6h       beep
251      * turn %s\n", (flag.beep) ? "off" : "on"); */
252     printf(CP[86], (flag.beep) ? CP[92] : CP[93]);
253     /* printf("2d2c+     move from 2d to 2c and promote\n"); */
254     printf(CP[128], (flag.material) ? CP[92] : CP[93]);
255     /* printf("P*5e      drop pawn to 5e         easy
256      * turn %s\n", (flag.easy) ? "off" : "on"); */
257     printf(CP[173], (flag.easy) ? CP[92] : CP[93]);
258     /* printf("                                  hash
259      * turn %s\n", (flag.hash) ? "off" : "on"); */
260     printf(CP[174], (flag.hash) ? CP[92] : CP[93]);
261     /* printf("bd        redraw board            reverse
262      * board display\n"); */
263     fputs(CP[130], stdout);
264     /* printf("list      game to shogi.lst       book
265      * turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount); */
266     printf(CP[170], (Book) ? CP[92] : CP[93], bookcount, booksize);
267     /* printf("undo      undo last ply           remove
268      * take back a move\n"); */
269     fputs(CP[200], stdout);
270     /* printf("edit      edit board              force
271      * enter game moves\n"); */
272     fputs(CP[153], stdout);
273     /* printf("switch    sides with computer     both
274      * computer match\n"); */
275     fputs(CP[194], stdout);
276     /* printf("black     computer plays black    white
277      * computer plays white\n"); */
278     fputs(CP[202], stdout);
279     /* printf("depth     set search depth        clock
280      * set time control\n"); */
281     fputs(CP[149], stdout);
282     /* printf("post      principle variation     hint
283      * suggest a move\n"); */
284     fputs(CP[177], stdout);
285     /* printf("save      game to file            get
286      * game from file\n"); */
287     fputs(CP[188], stdout);
288     printf("xsave     pos. to xshogi file     xget"
289            "      pos. from xshogi file\n");
290     /* printf("random    randomize play          new
291      * start new game\n"); */
292     fputs(CP[181], stdout);
293     printf("--------------------------------"
294            "--------------------------------\n");
295     /* printf("Computer: %-12s Opponent:            %s\n", */
296     printf(CP[46],
297            ColorStr[computer], ColorStr[opponent]);
298     /* printf("Depth:    %-12d Response time:       %d sec\n", */
299     printf(CP[51],
300            MaxSearchDepth, MaxResponseTime/100);
301     /* printf("Random:   %-12s Easy mode:           %s\n", */
302     printf(CP[99],
303            (dither) ? CP[93] : CP[92], (flag.easy) ? CP[93] : CP[92]);
304     /* printf("Beep:     %-12s Transposition file: %s\n", */
305     printf(CP[36],
306            (flag.beep) ? CP[93] : CP[92], (flag.hash) ? CP[93] : CP[92]);
307     /* printf("Tsume:    %-12s Force:               %s\n")*/
308     printf(CP[232],
309            (flag.tsume) ? CP[93] : CP[92], (flag.force) ? CP[93] : CP[92]);
310     /* printf("Time Control %s %d moves %d seconds %d opr %d
311      * depth\n", (TCflag) ? "ON" : "OFF", */
312     printf(CP[110],
313            (TCflag) ? CP[93] : CP[92],
314            TimeControl.moves[black], TimeControl.clock[black] / 100,
315            TCadd/100, MaxSearchDepth);
316
317     signal(SIGINT, Raw_TerminateSearch);
318     signal(SIGQUIT, Raw_TerminateSearch);
319 }
320
321
322
323 /*
324  * Set up a board position. Pieces are entered by typing the piece followed
325  * by the location. For example, Nf3 will place a knight on square f3.
326  */
327
328 void
329 Raw_EditBoard(void)
330 {
331     short a, r, c, sq, i, found;
332     char s[80];
333
334     flag.regularstart = true;
335     Book = BOOKFAIL;
336     Raw_ClearScreen();
337     Raw_UpdateDisplay(0, 0, 1, 0);
338     /* printf(".   exit to main\n"); */
339     fputs(CP[29], stdout);
340     /* printf("#   clear board\n"); */
341     fputs(CP[28], stdout);
342     /* printf("c   change sides\n"); */
343     fputs(CP[136], stdout);
344     /* printf("enter piece & location: \n"); */
345     fputs(CP[155], stdout);
346
347     a = black;
348
349     do
350     {
351         scanf("%s", s);
352         found = 0;
353
354         if (s[0] == CP[28][0])  /*#*/
355         {
356             for (sq = 0; sq < NO_SQUARES; sq++)
357             {
358                 board[sq] = no_piece;
359                 color[sq] = neutral;
360             }
361
362             ClearCaptured();
363         }
364
365         if (s[0] == CP[136][0]) /*c*/
366             a = otherside[a];
367
368         if (s[1] == '*')
369         {
370             for (i = pawn; i <= king; i++)
371             {
372                 if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
373                 {
374                     Captured[a][i]++;
375                     found = 1;
376                     break;
377                 }
378             }
379
380             c = -1;
381             r = -1;
382         }
383         else
384         {
385             c = COL_NAME(s[1]);
386             r = ROW_NAME(s[2]);
387         }
388
389         if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
390         {
391             sq = locn(r, c);
392             color[sq] = a;
393             board[sq] = no_piece;
394
395             for (i = no_piece; i <= king; i++)
396             {
397                 if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
398                 {
399                     if (s[3] == '+')
400                         board[sq] = promoted[i];
401                     else
402                         board[sq] = i;
403
404                     found = 1;
405                     break;
406                 }
407             }
408
409             if (found == 0)
410                 color[sq] = neutral;
411         }
412     }
413     while (s[0] != CP[29][0]);
414
415     for (sq = 0; sq < NO_SQUARES; sq++)
416         Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
417
418     GameCnt = 0;
419     Game50 = 1;
420     ZeroRPT();
421     Sdepth = 0;
422     InitializeStats();
423     Raw_ClearScreen();
424     Raw_UpdateDisplay(0, 0, 1, 0);
425 }
426
427
428
429
430 /*
431  * Set up a board position.
432  * Nine lines of nine characters are used to setup the board. 9a-1a is the
433  * first line. White pieces are  represented  by  uppercase characters.
434  */
435
436 void
437 SetupBoard(void)
438 {
439     short r, c, sq, i;
440     char ch;
441     char s[80];
442
443     NewGame();
444
445     fgets(s, 80, stdin);            /* skip "setup" command */
446
447     for (r = NO_ROWS - 1; r >= 0; r--)
448     {
449         fgets(s, 80, stdin);
450
451         for (c = 0; c <= (NO_COLS - 1); c++)
452         {
453             ch = s[c];
454             sq = locn(r, c);
455             color[sq] = neutral;
456             board[sq] = no_piece;
457
458             for (i = no_piece; i <= king; i++)
459             {
460                 if (ch == pxx[i])
461                 {
462                     color[sq] = white;
463                     board[sq] = i;
464                     break;
465                 }
466                 else if (ch == qxx[i])
467                 {
468                     color[sq] = black;
469                     board[sq] = i;
470                     break;
471                 }
472             }
473         }
474     }
475
476     for (sq = 0; sq < NO_SQUARES; sq++)
477         Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
478
479     InitializeStats();
480     Raw_ClearScreen();
481     Raw_UpdateDisplay(0, 0, 1, 0);
482     /* printf("Setup successful\n"); */
483     fputs(CP[106], stdout);
484 }
485
486
487 void
488 Raw_SearchStartStuff(short side)
489 {
490     signal(SIGINT, Raw_TerminateSearch);
491     signal(SIGQUIT, Raw_TerminateSearch);
492
493     if (flag.post)
494     {
495         printf(CP[123],
496                GameCnt/2 + 1,
497                ResponseTime, TimeControl.clock[side]);
498     }
499 }
500
501
502
503 void
504 Raw_OutputMove(void)
505 {
506     if (flag.illegal)
507     {
508         printf("%s\n", CP[225]);
509         return;
510     }
511
512     if (mvstr[0][0] == '\0')
513         goto nomove;
514
515     if (XSHOGI)
516     {
517         /* add remaining time in milliseconds to xshogi */
518         printf("%d. ... %s %ld\n", ++mycnt1, mvstr[0],
519                (TimeControl.clock[player] - et) * 10);
520     }
521     else
522     {
523         printf("%d. ... %s\n", ++mycnt1, mvstr[0]);
524     }
525
526  nomove:
527     if ((root->flags & draw) || (root->score == -(SCORE_LIMIT + 999))
528         || (root->score == (SCORE_LIMIT + 998)))
529         goto summary;
530
531     if (flag.post)
532     {
533         short h, l, t;
534
535         h = TREE;
536         l = 0;
537         t = TREE >> 1;
538
539         while (l != t)
540         {
541             if (Tree[t].f || Tree[t].t)
542                 l = t;
543             else
544                 h = t;
545
546             t = (l + h) >> 1;
547         }
548
549         /* printf("Nodes %ld Tree %d Eval %ld
550          * Rate %ld RS high %ld low %ld\n", */
551         printf(CP[89], GenCnt, NodeCnt, t, EvalNodes,
552                (et > 100) ? (NodeCnt / (et / 100)) : 0,
553                EADD, EGET, reminus, replus);
554
555         /* printf("Hin/Hout/Coll/Fin/Fout =
556          * %ld/%ld/%ld/%ld/%ld\n", */
557         printf(CP[71],
558                HashAdd, HashCnt, THashCol, HashCol, FHashCnt, FHashAdd);
559     }
560
561     Raw_UpdateDisplay(root->f, root->t, 0, root->flags);
562
563     if (!XSHOGI)
564     {
565         /* printf("My move is: %s\n", mvstr[0]); */
566         printf(CP[83], mvstr[0]);
567
568         if (flag.beep)
569             printf("%c", 7);
570     }
571
572  summary:
573     if (root->flags & draw)
574     {
575         /*  printf("Drawn game!\n"); */
576         fputs(CP[57], stdout);
577     }
578     else if (root->score == -(SCORE_LIMIT + 999))
579     {
580         printf("%s mates!\n", ColorStr[opponent]);
581     }
582     else if (root->score == (SCORE_LIMIT + 998))
583     {
584         printf("%s mates!\n", ColorStr[computer]);
585     }
586 #ifdef VERYBUGGY
587     else if (!barebones && (root->score < -SCORE_LIMIT))
588     {
589         printf("%s has a forced mate in %d moves!\n",
590                ColorStr[opponent], SCORE_LIMIT + 999 + root->score - 1);
591     }
592     else if (!barebones && (root->score > SCORE_LIMIT))
593     {
594         printf("%s has a forced mate in %d moves!\n",
595                ColorStr[computer], SCORE_LIMIT + 998 - root->score - 1);
596     }
597 #endif /* VERYBUGGY */
598 }
599
600
601 void
602 Raw_UpdateDisplay(short f, short t, short redraw, short isspec)
603 {
604
605     short r, c, l, m;
606
607     if (redraw && !XSHOGI)
608     {
609         printf("\n");
610         r = (short)(TimeControl.clock[black] / 6000);
611         c = (short)((TimeControl.clock[black] % 6000) / 100);
612         l = (short)(TimeControl.clock[white] / 6000);
613         m = (short)((TimeControl.clock[white] % 6000) / 100);
614         /* printf("Black %d:%02d  White %d:%02d\n", r, c, l, m); */
615         printf(CP[116], r, c, l, m);
616         printf("\n");
617
618         for (r = (NO_ROWS - 1); r >= 0; r--)
619         {
620             for (c = 0; c <= (NO_COLS - 1); c++)
621             {
622                 char pc;
623                 l = ((flag.reverse)
624                      ? locn((NO_ROWS - 1) - r, (NO_COLS - 1) - c)
625                      : locn(r, c));
626                 pc = (is_promoted[board[l]] ? '+' : ' ');
627
628                 if (color[l] == neutral)
629                     printf(" -");
630                 else if (color[l] == black)
631                     printf("%c%c", pc, qxx[board[l]]);
632                 else
633                     printf("%c%c", pc, pxx[board[l]]);
634             }
635
636             printf("\n");
637         }
638
639         printf("\n");
640         {
641             short side;
642
643             for (side = black; side <= white; side++)
644             {
645                 short piece, c;
646                 printf((side == black)?"black ":"white ");
647
648                 for (piece = pawn; piece <= king; piece++)
649                 {
650                     if ((c = Captured[side][piece]))
651                         printf("%i%c ", c, pxx[piece]);
652                 }
653
654                 printf("\n");
655             }
656         }
657     }
658 }
659
660
661
662 void
663 Raw_ChangeAlphaWindow(void)
664 {
665     printf("WAwindow: ");
666     scanf("%hd", &WAwindow);
667     printf("BAwindow: ");
668     scanf("%hd", &BAwindow);
669 }
670
671
672
673 void
674 Raw_ChangeBetaWindow(void)
675 {
676     printf("WBwindow: ");
677     scanf("%hd", &WBwindow);
678     printf("BBwindow: ");
679     scanf("%hd", &BBwindow);
680 }
681
682
683
684 void
685 Raw_GiveHint(void)
686 {
687     if (hint)
688     {
689         algbr((short) (hint >> 8), (short) (hint & 0xFF), false);
690         printf(CP[72], mvstr[0]);   /*hint*/
691     }
692     else
693         fputs(CP[223], stdout);
694 }
695
696
697
698 void
699 Raw_SelectLevel(char *sx)
700 {
701
702     char T[NO_SQUARES + 1], *p, *q;
703
704     if ((p = strstr(sx, CP[169])) != NULL)
705         p += strlen(CP[169]);
706     else if ((p = strstr(sx, CP[217])) != NULL)
707         p += strlen(CP[217]);
708
709     strcat(sx, "XX");
710     q = T;
711     *q = '\0';
712
713     for (; *p != 'X'; *q++ = *p++);
714
715     *q = '\0';
716
717     /* line empty ask for input */
718     if (!T[0])
719     {
720         fputs(CP[61], stdout);
721         fgets(T, NO_SQUARES + 1, stdin);
722         strcat(T, "XX");
723     }
724
725     /* skip blackspace */
726     for (p = T; *p == ' '; p++) ;
727
728     /* could be moves or a fischer clock */
729     if (*p == 'f')
730     {
731         /* its a fischer clock game */
732         p++;
733         TCminutes = (short)strtol(p, &q, 10);
734         TCadd = (short)strtol(q, NULL, 10) *100;
735         TCseconds = 0;
736         TCmoves = 50;
737     }
738     else
739     {
740         /* regular game */
741         TCadd = 0;
742         TCmoves = (short)strtol(p, &q, 10);
743         TCminutes = (short)strtol(q, &q, 10);
744
745         if (*q == ':')
746             TCseconds = (short)strtol(q + 1, (char **) NULL, 10);
747         else
748             TCseconds = 0;
749
750 #ifdef OPERATORTIME
751         fputs(CP[94], stdout);
752         scanf("%hd", &OperatorTime);
753 #endif
754
755         if (TCmoves == 0)
756         {
757             TCflag = false;
758             MaxResponseTime = TCminutes*60L * 100L + TCseconds * 100L;
759             TCminutes = TCseconds = 0;
760         }
761         else
762         {
763             TCflag = true;
764             MaxResponseTime = 0;
765         }
766     }
767
768     TimeControl.clock[black] = TimeControl.clock[white] = 0;
769     SetTimeControl();
770
771     if (XSHOGI)
772     {
773         printf("Clocks: %ld %ld\n",
774                TimeControl.clock[black] * 10,
775                TimeControl.clock[white] * 10);
776     }
777 }
778
779
780
781
782 void
783 Raw_ChangeSearchDepth(void)
784 {
785     printf("depth = ");
786     scanf("%hd", &MaxSearchDepth);
787     TCflag = !(MaxSearchDepth > 0);
788 }
789
790
791
792
793 void
794 Raw_ChangeHashDepth(void)
795 {
796     printf("hashdepth = ");
797     scanf("%hd", &HashDepth);
798     printf("MoveLimit = ");
799     scanf("%hd", &HashMoveLimit);
800 }
801
802
803
804 void
805 Raw_SetContempt(void)
806 {
807     printf("contempt = ");
808     scanf("%hd", &contempt);
809 }
810
811
812
813 void
814 Raw_ChangeXwindow(void)
815 {
816     printf("xwndw = ");
817     scanf("%hd", &xwndw);
818 }
819
820
821 /*
822  * Raw_ShowPostnValue(short sq)
823  * must have called ExaminePosition() first
824  */
825
826 void
827 Raw_ShowPostnValue(short sq)
828 {
829     short score;
830     score = ScorePosition(color[sq]);
831
832     if (color[sq] != neutral)
833     {
834 #if defined SAVE_SVALUE
835         printf("???%c ", (color[sq] == white)?'b':'w');
836 #else
837         printf("%3d%c ", svalue[sq], (color[sq] == white)?'b':'w');
838 #endif
839     }
840     else
841     {
842         printf(" *   ");
843     }
844 }
845
846
847
848 void
849 Raw_DoDebug(void)
850 {
851     short c, p, sq, tp, tc, tsq, score, j, k;
852     char s[40];
853
854     ExaminePosition(opponent);
855     Raw_ShowMessage(CP[65]);
856     scanf("%s", s);
857     c = neutral;
858
859     if ((s[0] == CP[9][0]) || (s[0] == CP[9][1]))    /* w W */
860         c = black;
861
862     if ((s[0] == CP[9][2]) || (s[0] == CP[9][3]))    /* b B */
863         c = white;
864
865     for (p = king; p > no_piece; p--)
866     {
867         if ((s[1] == pxx[p]) || (s[1] == qxx[p]))
868             break;
869     }
870
871     if (p > no_piece)
872     {
873         for (j = (NO_ROWS - 1); j >= 0; j--)
874         {
875             for (k = 0; k < (NO_COLS); k++)
876             {
877                 sq = j*(NO_COLS) + k;
878                 tp = board[sq];
879                 tc = color[sq];
880                 board[sq] = p;
881                 color[sq] = c;
882                 tsq = PieceList[c][1];
883                 PieceList[c][1] = sq;
884                 Raw_ShowPostnValue(sq);
885                 PieceList[c][1] = tsq;
886                 board[sq] = tp;
887                 color[sq] = tc;
888             }
889
890             printf("\n");
891         }
892     }
893
894     score = ScorePosition(opponent);
895
896     for (j = (NO_ROWS - 1); j >= 0; j--)
897     {
898         for (k = 0; k < (NO_COLS); k++)
899         {
900             sq = j*(NO_COLS) + k;
901
902             if (color[sq] != neutral)
903             {
904 #if defined SAVE_SVALUE
905                 printf("%?????%c ", (color[sq] == white)?'b':'w');
906 #else
907                 printf("%5d%c ", svalue[sq], (color[sq] == white)?'b':'w');
908 #endif
909             }
910             else
911             {
912                 printf("    *  ");
913             }
914         }
915
916         printf("\n");
917     }
918
919     printf("stage = %d\n", stage);
920     printf(CP[103], score,
921            mtl[computer], pscore[computer], GameType[computer],
922            mtl[opponent], pscore[opponent], GameType[opponent]);
923 }
924
925
926
927 void
928 Raw_DoTable(short table[NO_SQUARES])
929 {
930     short  sq, j, k;
931     ExaminePosition(opponent);
932
933     for (j = (NO_ROWS - 1); j >= 0; j--)
934     {
935         for (k = 0; k < NO_COLS; k++)
936         {
937             sq = j*(NO_ROWS) + k;
938             printf("%3d ", table[sq]);
939         }
940
941         printf("\n");
942     }
943 }
944
945
946
947 void
948 Raw_ShowPostnValues(void)
949 {
950     short sq, score, j, k;
951     ExaminePosition(opponent);
952
953     for (j = (NO_ROWS - 1); j >= 0; j--)
954     {
955         for (k = 0; k < NO_COLS; k++)
956         {
957             sq = j * NO_COLS + k;
958             Raw_ShowPostnValue(sq);
959         }
960
961         printf("\n");
962     }
963
964     score = ScorePosition(opponent);
965     printf(CP[103], score,
966            mtl[computer], pscore[computer], GameType[computer],
967            mtl[opponent], pscore[opponent], GameType[opponent]);
968     printf("\nhung black %d hung white %d\n", hung[black], hung[white]);
969 }
970