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