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