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