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