Changing license to GPL3 (and bumping version to 1.4.0).
[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         printf(CP[124]);
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]);
242     printf("----------------------------------"
243            "------------------------------\n");
244     /* printf("7g7f      move from 7g to 7f      quit
245      * Exit Shogi\n"); */
246     printf(CP[158]);
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     printf(CP[130]);
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     printf(CP[200]);
267     /* printf("edit      edit board              force
268      * enter game moves\n"); */
269     printf(CP[153]);
270     /* printf("switch    sides with computer     both
271      * computer match\n"); */
272     printf(CP[194]);
273     /* printf("black     computer plays black    white
274      * computer plays white\n"); */
275     printf(CP[202]);
276     /* printf("depth     set search depth        clock
277      * set time control\n"); */
278     printf(CP[149]);
279     /* printf("post      principle variation     hint
280      * suggest a move\n"); */
281     printf(CP[177]);
282     /* printf("save      game to file            get
283      * game from file\n"); */
284     printf(CP[188]);
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     printf(CP[181]);
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(SIGINT, Raw_TerminateSearch);
315     signal(SIGQUIT, Raw_TerminateSearch);
316 }
317
318
319
320 /*
321  * Set up a board position. Pieces are entered by typing the piece followed
322  * by the location. For example, Nf3 will place a knight on square f3.
323  */
324
325 void
326 Raw_EditBoard(void)
327 {
328     short a, r, c, sq, i, found;
329     char s[80];
330
331     flag.regularstart = true;
332     Book = BOOKFAIL;
333     Raw_ClearScreen();
334     Raw_UpdateDisplay(0, 0, 1, 0);
335     /* printf(".   exit to main\n"); */
336     printf(CP[29]);
337     /* printf("#   clear board\n"); */
338     printf(CP[28]);
339     /* printf("c   change sides\n"); */
340     printf(CP[136]);
341     /* printf("enter piece & location: \n"); */
342     printf(CP[155]);
343
344     a = black;
345
346     do
347     {
348         scanf("%s", s);
349         found = 0;
350
351         if (s[0] == CP[28][0])  /*#*/
352         {
353             for (sq = 0; sq < NO_SQUARES; sq++)
354             {
355                 board[sq] = no_piece;
356                 color[sq] = neutral;
357             }
358
359             ClearCaptured();
360         }
361
362         if (s[0] == CP[136][0]) /*c*/
363             a = otherside[a];
364
365         if (s[1] == '*')
366         {
367             for (i = pawn; i <= king; i++)
368             {
369                 if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
370                 {
371                     Captured[a][i]++;
372                     found = 1;
373                     break;
374                 }
375             }
376
377             c = -1;
378             r = -1;
379         }
380         else
381         {
382             c = '9' - s[1];
383             r = 'i' - s[2];
384         }
385
386         if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
387         {
388             sq = locn(r, c);
389             color[sq] = a;
390             board[sq] = no_piece;
391
392             for (i = no_piece; i <= king; i++)
393             {
394                 if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
395                 {
396                     if (s[3] == '+')
397                         board[sq] = promoted[i];
398                     else
399                         board[sq] = i;
400
401                     found = 1;
402                     break;
403                 }
404             }
405
406             if (found == 0)
407                 color[sq] = neutral;
408         }
409     }
410     while (s[0] != CP[29][0]);
411
412     for (sq = 0; sq < NO_SQUARES; sq++)
413         Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
414
415     GameCnt = 0;
416     Game50 = 1;
417     ZeroRPT();
418     Sdepth = 0;
419     InitializeStats();
420     Raw_ClearScreen();
421     Raw_UpdateDisplay(0, 0, 1, 0);
422 }
423
424
425
426
427 /*
428  * Set up a board position.
429  * Nine lines of nine characters are used to setup the board. 9a-1a is the
430  * first line. White pieces are  represented  by  uppercase characters.
431  */
432
433 void
434 SetupBoard(void)
435 {
436     short r, c, sq, i;
437     char ch;
438     char s[80];
439
440     NewGame();
441
442     fgets(s, 80, stdin);            /* skip "setup" command */
443
444     for (r = NO_ROWS - 1; r >= 0; r--)
445     {
446         fgets(s, 80, stdin);
447
448         for (c = 0; c <= (NO_COLS - 1); c++)
449         {
450             ch = s[c];
451             sq = locn(r, c);
452             color[sq] = neutral;
453             board[sq] = no_piece;
454
455             for (i = no_piece; i <= king; i++)
456             {
457                 if (ch == pxx[i])
458                 {
459                     color[sq] = white;
460                     board[sq] = i;
461                     break;
462                 }
463                 else if (ch == qxx[i])
464                 {
465                     color[sq] = black;
466                     board[sq] = i;
467                     break;
468                 }
469             }
470         }
471     }
472
473     for (sq = 0; sq < NO_SQUARES; sq++)
474         Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
475
476     InitializeStats();
477     Raw_ClearScreen();
478     Raw_UpdateDisplay(0, 0, 1, 0);
479     /* printf("Setup successful\n"); */
480     printf(CP[106]);
481 }
482
483
484 void
485 Raw_SearchStartStuff(short side)
486 {
487     signal(SIGINT, Raw_TerminateSearch);
488     signal(SIGQUIT, Raw_TerminateSearch);
489
490     if (flag.post)
491     {
492         printf(CP[123],
493                GameCnt/2 + 1,
494                ResponseTime, TimeControl.clock[side]);
495     }
496 }
497
498
499
500 void
501 Raw_OutputMove(void)
502 {
503     if (flag.illegal)
504     {
505         printf("%s\n", CP[225]);
506         return;
507     }
508
509     if (mvstr[0][0] == '\0')
510         goto nomove;
511
512     if (XSHOGI)
513     {
514         /* add remaining time in milliseconds to xshogi */
515         printf("%d. ... %s %ld\n", ++mycnt1, mvstr[0],
516                (TimeControl.clock[player] - et) * 10);
517     }
518     else
519     {
520         printf("%d. ... %s\n", ++mycnt1, mvstr[0]);
521     }
522
523  nomove:
524     if ((root->flags & draw) || (root->score == -(SCORE_LIMIT + 999))
525         || (root->score == (SCORE_LIMIT + 998)))
526         goto summary;
527
528     if (flag.post)
529     {
530         short h, l, t;
531
532         h = TREE;
533         l = 0;
534         t = TREE >> 1;
535
536         while (l != t)
537         {
538             if (Tree[t].f || Tree[t].t)
539                 l = t;
540             else
541                 h = t;
542
543             t = (l + h) >> 1;
544         }
545
546         /* printf("Nodes %ld Tree %d Eval %ld
547          * Rate %ld RS high %ld low %ld\n", */
548         printf(CP[89], GenCnt, NodeCnt, t, EvalNodes,
549                (et > 100) ? (NodeCnt / (et / 100)) : 0,
550                EADD, EGET, reminus, replus);
551
552         /* printf("Hin/Hout/Coll/Fin/Fout =
553          * %ld/%ld/%ld/%ld/%ld\n", */
554         printf(CP[71],
555                HashAdd, HashCnt, THashCol, HashCol, FHashCnt, FHashAdd);
556     }
557
558     Raw_UpdateDisplay(root->f, root->t, 0, root->flags);
559
560     if (!XSHOGI)
561     {
562         /* printf("My move is: %s\n", mvstr[0]); */
563         printf(CP[83], mvstr[0]);
564
565         if (flag.beep)
566             printf("%c", 7);
567     }
568
569  summary:
570     if (root->flags & draw)
571     {
572         /*  printf("Drawn game!\n"); */
573         printf(CP[57]);
574     }
575     else if (root->score == -(SCORE_LIMIT + 999))
576     {
577         printf("%s mates!\n", ColorStr[opponent]);
578     }
579     else if (root->score == (SCORE_LIMIT + 998))
580     {
581         printf("%s mates!\n", ColorStr[computer]);
582     }
583 #ifdef VERYBUGGY
584     else if (!barebones && (root->score < -SCORE_LIMIT))
585     {
586         printf("%s has a forced mate in %d moves!\n",
587                ColorStr[opponent], SCORE_LIMIT + 999 + root->score - 1);
588     }
589     else if (!barebones && (root->score > SCORE_LIMIT))
590     {
591         printf("%s has a forced mate in %d moves!\n",
592                ColorStr[computer], SCORE_LIMIT + 998 - root->score - 1);
593     }
594 #endif /* VERYBUGGY */
595 }
596
597
598 void
599 Raw_UpdateDisplay(short f, short t, short redraw, short isspec)
600 {
601
602     short r, c, l, m;
603
604     if (redraw && !XSHOGI)
605     {
606         printf("\n");
607         r = (short)(TimeControl.clock[black] / 6000);
608         c = (short)((TimeControl.clock[black] % 6000) / 100);
609         l = (short)(TimeControl.clock[white] / 6000);
610         m = (short)((TimeControl.clock[white] % 6000) / 100);
611         /* printf("Black %d:%02d  White %d:%02d\n", r, c, l, m); */
612         printf(CP[116], r, c, l, m);
613         printf("\n");
614
615         for (r = (NO_ROWS - 1); r >= 0; r--)
616         {
617             for (c = 0; c <= (NO_COLS - 1); c++)
618             {
619                 char pc;
620                 l = ((flag.reverse)
621                      ? locn((NO_ROWS - 1) - r, (NO_COLS - 1) - c)
622                      : locn(r, c));
623                 pc = (is_promoted[board[l]] ? '+' : ' ');
624
625                 if (color[l] == neutral)
626                     printf(" -");
627                 else if (color[l] == black)
628                     printf("%c%c", pc, qxx[board[l]]);
629                 else
630                     printf("%c%c", pc, pxx[board[l]]);
631             }
632
633             printf("\n");
634         }
635
636         printf("\n");
637         {
638             short side;
639
640             for (side = black; side <= white; side++)
641             {
642                 short piece, c;
643                 printf((side == black)?"black ":"white ");
644
645                 for (piece = pawn; piece <= king; piece++)
646                 {
647                     if ((c = Captured[side][piece]))
648                         printf("%i%c ", c, pxx[piece]);
649                 }
650
651                 printf("\n");
652             }
653         }
654     }
655 }
656
657
658
659 void
660 Raw_ChangeAlphaWindow(void)
661 {
662     printf("WAwindow: ");
663     scanf("%hd", &WAwindow);
664     printf("BAwindow: ");
665     scanf("%hd", &BAwindow);
666 }
667
668
669
670 void
671 Raw_ChangeBetaWindow(void)
672 {
673     printf("WBwindow: ");
674     scanf("%hd", &WBwindow);
675     printf("BBwindow: ");
676     scanf("%hd", &BBwindow);
677 }
678
679
680
681 void
682 Raw_GiveHint(void)
683 {
684     if (hint)
685     {
686         algbr((short) (hint >> 8), (short) (hint & 0xFF), false);
687         printf(CP[72], mvstr[0]);   /*hint*/
688     }
689     else
690         printf(CP[223]);
691 }
692
693
694
695 void
696 Raw_SelectLevel(char *sx)
697 {
698
699     char T[NO_SQUARES + 1], *p, *q;
700
701     if ((p = strstr(sx, CP[169])) != NULL)
702         p += strlen(CP[169]);
703     else if ((p = strstr(sx, CP[217])) != NULL)
704         p += strlen(CP[217]);
705
706     strcat(sx, "XX");
707     q = T;
708     *q = '\0';
709
710     for (; *p != 'X'; *q++ = *p++);
711
712     *q = '\0';
713
714     /* line empty ask for input */
715     if (!T[0])
716     {
717         printf(CP[61]);
718         fgets(T, NO_SQUARES + 1, stdin);
719         strcat(T, "XX");
720     }
721
722     /* skip blackspace */
723     for (p = T; *p == ' '; p++) ;
724
725     /* could be moves or a fischer clock */
726     if (*p == 'f')
727     {
728         /* its a fischer clock game */
729         p++;
730         TCminutes = (short)strtol(p, &q, 10);
731         TCadd = (short)strtol(q, NULL, 10) *100;
732         TCseconds = 0;
733         TCmoves = 50;
734     }
735     else
736     {
737         /* regular game */
738         TCadd = 0;
739         TCmoves = (short)strtol(p, &q, 10);
740         TCminutes = (short)strtol(q, &q, 10);
741
742         if (*q == ':')
743             TCseconds = (short)strtol(q + 1, (char **) NULL, 10);
744         else
745             TCseconds = 0;
746
747 #ifdef OPERATORTIME
748         printf(CP[94]);
749         scanf("%hd", &OperatorTime);
750 #endif
751
752         if (TCmoves == 0)
753         {
754             TCflag = false;
755             MaxResponseTime = TCminutes*60L * 100L + TCseconds * 100L;
756             TCminutes = TCseconds = 0;
757         }
758         else
759         {
760             TCflag = true;
761             MaxResponseTime = 0;
762         }
763     }
764
765     TimeControl.clock[black] = TimeControl.clock[white] = 0;
766     SetTimeControl();
767
768     if (XSHOGI)
769     {
770         printf("Clocks: %ld %ld\n",
771                TimeControl.clock[black] * 10,
772                TimeControl.clock[white] * 10);
773     }
774 }
775
776
777
778
779 void
780 Raw_ChangeSearchDepth(void)
781 {
782     printf("depth = ");
783     scanf("%hd", &MaxSearchDepth);
784     TCflag = !(MaxSearchDepth > 0);
785 }
786
787
788
789
790 void
791 Raw_ChangeHashDepth(void)
792 {
793     printf("hashdepth = ");
794     scanf("%hd", &HashDepth);
795     printf("MoveLimit = ");
796     scanf("%hd", &HashMoveLimit);
797 }
798
799
800
801 void
802 Raw_SetContempt(void)
803 {
804     printf("contempt = ");
805     scanf("%hd", &contempt);
806 }
807
808
809
810 void
811 Raw_ChangeXwindow(void)
812 {
813     printf("xwndw = ");
814     scanf("%hd", &xwndw);
815 }
816
817
818 /*
819  * Raw_ShowPostnValue(short sq)
820  * must have called ExaminePosition() first
821  */
822
823 void
824 Raw_ShowPostnValue(short sq)
825 {
826     short score;
827     score = ScorePosition(color[sq]);
828
829     if (color[sq] != neutral)
830     {
831 #if defined SAVE_SVALUE
832         printf("???%c ", (color[sq] == white)?'b':'w');
833 #else
834         printf("%3d%c ", svalue[sq], (color[sq] == white)?'b':'w');
835 #endif
836     }
837     else
838     {
839         printf(" *   ");
840     }
841 }
842
843
844
845 void
846 Raw_DoDebug(void)
847 {
848     short c, p, sq, tp, tc, tsq, score, j, k;
849     char s[40];
850
851     ExaminePosition(opponent);
852     Raw_ShowMessage(CP[65]);
853     scanf("%s", s);
854     c = neutral;
855
856     if ((s[0] == CP[9][0]) || (s[0] == CP[9][1]))    /* w W */
857         c = black;
858
859     if ((s[0] == CP[9][2]) || (s[0] == CP[9][3]))    /* b B */
860         c = white;
861
862     for (p = king; p > no_piece; p--)
863     {
864         if ((s[1] == pxx[p]) || (s[1] == qxx[p]))
865             break;
866     }
867
868     if (p > no_piece)
869     {
870         for (j = (NO_ROWS - 1); j >= 0; j--)
871         {
872             for (k = 0; k < (NO_COLS); k++)
873             {
874                 sq = j*(NO_COLS) + k;
875                 tp = board[sq];
876                 tc = color[sq];
877                 board[sq] = p;
878                 color[sq] = c;
879                 tsq = PieceList[c][1];
880                 PieceList[c][1] = sq;
881                 Raw_ShowPostnValue(sq);
882                 PieceList[c][1] = tsq;
883                 board[sq] = tp;
884                 color[sq] = tc;
885             }
886
887             printf("\n");
888         }
889     }
890
891     score = ScorePosition(opponent);
892
893     for (j = (NO_ROWS - 1); j >= 0; j--)
894     {
895         for (k = 0; k < (NO_COLS); k++)
896         {
897             sq = j*(NO_COLS) + k;
898
899             if (color[sq] != neutral)
900             {
901 #if defined SAVE_SVALUE
902                 printf("%?????%c ", (color[sq] == white)?'b':'w');
903 #else
904                 printf("%5d%c ", svalue[sq], (color[sq] == white)?'b':'w');
905 #endif
906             }
907             else
908             {
909                 printf("    *  ");
910             }
911         }
912
913         printf("\n");
914     }
915
916     printf("stage = %d\n", stage);
917     printf(CP[103], score,
918            mtl[computer], pscore[computer], GameType[computer],
919            mtl[opponent], pscore[opponent], GameType[opponent]);
920 }
921
922
923
924 void
925 Raw_DoTable(short table[NO_SQUARES])
926 {
927     short  sq, j, k;
928     ExaminePosition(opponent);
929
930     for (j = (NO_ROWS - 1); j >= 0; j--)
931     {
932         for (k = 0; k < NO_COLS; k++)
933         {
934             sq = j*(NO_ROWS) + k;
935             printf("%3d ", table[sq]);
936         }
937
938         printf("\n");
939     }
940 }
941
942
943
944 void
945 Raw_ShowPostnValues(void)
946 {
947     short sq, score, j, k;
948     ExaminePosition(opponent);
949
950     for (j = (NO_ROWS - 1); j >= 0; j--)
951     {
952         for (k = 0; k < NO_COLS; k++)
953         {
954             sq = j * NO_COLS + k;
955             Raw_ShowPostnValue(sq);
956         }
957
958         printf("\n");
959     }
960
961     score = ScorePosition(opponent);
962     printf(CP[103], score,
963            mtl[computer], pscore[computer], GameType[computer],
964            mtl[opponent], pscore[opponent], GameType[opponent]);
965     printf("\nhung black %d hung white %d\n", hung[black], hung[white]);
966 }
967