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