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