~ubuntu-branches/ubuntu/precise/gcompris/precise

« back to all changes in this revision

Viewing changes to src/chess_computer-activity/gnuchess/output.c

  • Committer: Bazaar Package Importer
  • Author(s): Yann Dirson
  • Date: 2010-06-27 22:51:30 UTC
  • mfrom: (1.1.16 upstream) (5.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100627225130-mf7h4m5r8m7bd9fb
Tags: 9.3-1
* New upstream release.
* Drop GTK_DISABLE_DEPRECATED patch, useless for now.
* Provide RELEASE_NOTE_9.3.txt downloaded from sourceforge.
* New voice package for Asturian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GNU Chess 5.0 - output.c - output code
 
2
   Copyright (c) 1999-2002 Free Software Foundation, Inc.
 
3
 
 
4
   GNU Chess is based on the two research programs 
 
5
   Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
6
 
 
7
   GNU Chess is free software; you can redistribute it and/or modify
 
8
   it under the terms of the GNU General Public License as published by
 
9
   the Free Software Foundation; either version 2, or (at your option)
 
10
   any later version.
 
11
 
 
12
   GNU Chess is distributed in the hope that it will be useful,
 
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
   GNU General Public License for more details.
 
16
 
 
17
   You should have received a copy of the GNU General Public License
 
18
   along with GNU Chess; see the file COPYING.  If not, write to
 
19
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
   Boston, MA 02111-1307, USA.
 
21
 
 
22
   Contact Info: 
 
23
     bug-gnu-chess@gnu.org
 
24
     cracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net
 
25
*/
 
26
/*
 
27
 *
 
28
 */
 
29
 
 
30
#include <config.h>
 
31
#include <stdio.h>
 
32
#include "common.h"
 
33
 
 
34
void ShowTime (void)
 
35
/**************************************************************************
 
36
 *
 
37
 *  Print out the time settings.
 
38
 *
 
39
 **************************************************************************/
 
40
{
 
41
}
 
42
 
 
43
void ShowMoveList (int ply)
 
44
/**************************************************************************
 
45
 *
 
46
 *  Print out the move list.  
 
47
 *
 
48
 **************************************************************************/
 
49
{
 
50
   leaf *node;
 
51
   int i = 0;
 
52
   
 
53
   for (node = TreePtr[ply]; node < TreePtr[ply+1]; node++)
 
54
   {
 
55
      SANMove (node->move, ply); 
 
56
      printf ("%5s %3d\t", SANmv, SwapOff(node->move));
 
57
      if (++i == 5)
 
58
      {
 
59
         printf ("\n"); 
 
60
         i = 0;
 
61
      }
 
62
   }
 
63
   printf ("\n");
 
64
 
65
 
 
66
 
 
67
void ShowSmallBoard (void)     
 
68
/*****************************************************************************
 
69
 *
 
70
 *  Display the board.  Not only that but display some useful information
 
71
 *  like whether enpassant is legal and castling state.
 
72
 *
 
73
 *****************************************************************************/ 
 
74
{
 
75
   int r, c, sq;
 
76
 
 
77
   printf ("\n");
 
78
   if (board.side == white)
 
79
      printf ("white  ");
 
80
   else
 
81
      printf ("black  ");
 
82
 
 
83
   if (board.flag & WKINGCASTLE)
 
84
      printf ("K");
 
85
   if (board.flag & WQUEENCASTLE)
 
86
      printf ("Q");
 
87
   if (board.flag & BKINGCASTLE)
 
88
      printf ("k");
 
89
   if (board.flag & BQUEENCASTLE)
 
90
      printf ("q");
 
91
 
 
92
   if (board.ep > -1)
 
93
      printf ("  %s", algbr[board.ep]);
 
94
 
 
95
   printf ("\n");
 
96
   for (r = 56; r >= 0; r -= 8)
 
97
   {
 
98
      for (c = 0; c < 8; c++)
 
99
      {
 
100
         sq = r + c;
 
101
         if (board.b[white][pawn] & BitPosArray[sq])
 
102
            printf ("P ");
 
103
         else if (board.b[white][knight] & BitPosArray[sq])
 
104
            printf ("N ");
 
105
         else if (board.b[white][bishop] & BitPosArray[sq])
 
106
            printf ("B ");
 
107
         else if (board.b[white][rook]   & BitPosArray[sq])
 
108
            printf ("R ");
 
109
         else if (board.b[white][queen]  & BitPosArray[sq])
 
110
            printf ("Q ");
 
111
         else if (board.b[white][king]   & BitPosArray[sq])
 
112
            printf ("K ");
 
113
         else if (board.b[black][pawn]   & BitPosArray[sq])
 
114
            printf ("p ");
 
115
         else if (board.b[black][knight] & BitPosArray[sq])
 
116
            printf ("n ");
 
117
         else if (board.b[black][bishop] & BitPosArray[sq])
 
118
            printf ("b ");
 
119
         else if (board.b[black][rook]   & BitPosArray[sq])
 
120
            printf ("r ");
 
121
         else if (board.b[black][queen]  & BitPosArray[sq])
 
122
            printf ("q ");
 
123
         else if (board.b[black][king]   & BitPosArray[sq])
 
124
            printf ("k ");
 
125
         else
 
126
            printf (". ");
 
127
      }
 
128
      printf ("\n");
 
129
   }
 
130
   printf ("\n");
 
131
}
 
132
  
 
133
 
 
134
 
 
135
void ShowBitBoard (BitBoard *b)
 
136
/*****************************************************************************
 
137
 *
 
138
 * Just to print a lousy ascii board  
 
139
 *
 
140
 *****************************************************************************/
 
141
{
 
142
   int r, c;
 
143
 
 
144
   printf ("\n");
 
145
   for (r = 56; r >= 0; r -= 8)
 
146
   {
 
147
      for (c = 0; c < 8; c++)
 
148
      {
 
149
         if (*b & BitPosArray[r + c])
 
150
            printf ("1 ");
 
151
         else
 
152
            printf (". "); 
 
153
      }
 
154
      printf ("\n");
 
155
   }
 
156
   printf ("\n");
 
157
}
 
158
 
 
159
 
 
160
void ShowBoard (void)     
 
161
/*****************************************************************************
 
162
 *
 
163
 *  Display the board.  Not only that but display some useful information
 
164
 *  like whether enpassant is legal and castling state.
 
165
 *
 
166
 *****************************************************************************/ 
 
167
{
 
168
   int r, c, sq;
 
169
 
 
170
   fprintf (ofp, "\n");
 
171
   if (board.side == white)
 
172
      fprintf (ofp, "white  ");
 
173
   else
 
174
      fprintf (ofp, "black  ");
 
175
 
 
176
   if (board.flag & WKINGCASTLE)
 
177
      fprintf (ofp, "K");
 
178
   if (board.flag & WQUEENCASTLE)
 
179
      fprintf (ofp, "Q");
 
180
   if (board.flag & BKINGCASTLE)
 
181
      fprintf (ofp, "k");
 
182
   if (board.flag & BQUEENCASTLE)
 
183
      fprintf (ofp, "q");
 
184
 
 
185
   if (board.ep > -1)
 
186
      fprintf (ofp, "  %s", algbr[board.ep]);
 
187
 
 
188
   fprintf (ofp, "\n");
 
189
   for (r = 56; r >= 0; r -= 8)
 
190
   {
 
191
      for (c = 0; c < 8; c++)
 
192
      {
 
193
         sq = r + c;
 
194
         if (board.b[white][pawn]   & BitPosArray[sq])
 
195
            fprintf (ofp, "P ");
 
196
         else if (board.b[white][knight] & BitPosArray[sq])
 
197
            fprintf (ofp, "N ");
 
198
         else if (board.b[white][bishop] & BitPosArray[sq])
 
199
            fprintf (ofp, "B ");
 
200
         else if (board.b[white][rook]   & BitPosArray[sq])
 
201
            fprintf (ofp, "R ");
 
202
         else if (board.b[white][queen]  & BitPosArray[sq])
 
203
            fprintf (ofp, "Q ");
 
204
         else if (board.b[white][king]   & BitPosArray[sq])
 
205
            fprintf (ofp, "K ");
 
206
         else if (board.b[black][pawn]   & BitPosArray[sq])
 
207
            fprintf (ofp, "p ");
 
208
         else if (board.b[black][knight] & BitPosArray[sq])
 
209
            fprintf (ofp, "n ");
 
210
         else if (board.b[black][bishop] & BitPosArray[sq])
 
211
            fprintf (ofp, "b ");
 
212
         else if (board.b[black][rook]   & BitPosArray[sq])
 
213
            fprintf (ofp, "r ");
 
214
         else if (board.b[black][queen]  & BitPosArray[sq])
 
215
            fprintf (ofp, "q ");
 
216
         else if (board.b[black][king]   & BitPosArray[sq])
 
217
            fprintf (ofp, "k ");
 
218
         else
 
219
            fprintf (ofp, ". ");
 
220
      }
 
221
      fprintf (ofp, "\n");
 
222
   }
 
223
   fprintf (ofp, "\n");
 
224
}
 
225
 
 
226
void ShowCBoard (void)
 
227
/*****************************************************************************
 
228
 *
 
229
 *
 
230
 *
 
231
 *****************************************************************************/
 
232
{
 
233
   int r, c;
 
234
 
 
235
   for (r = 56; r >= 0; r -= 8)
 
236
   {
 
237
      for (c = 0; c < 8; c++)
 
238
      {
 
239
         printf ("%2c ", cboard[r + c] ? notation[cboard[r+c]] : '.');
 
240
      }
 
241
      printf ("\n");
 
242
   }
 
243
   printf ("\n");
 
244
}
 
245
 
 
246
 
 
247
void ShowMvboard (void)
 
248
/*****************************************************************************
 
249
 *
 
250
 *  Print the Mvboard[] array.
 
251
 *
 
252
 *****************************************************************************/
 
253
{
 
254
   int r, c;
 
255
 
 
256
   for (r = 56; r >= 0; r -= 8)
 
257
   {
 
258
      for (c = 0; c < 8; c++)
 
259
      {
 
260
         printf ("%2d ", Mvboard[r + c]);
 
261
      }
 
262
      printf ("\n");
 
263
   }
 
264
   printf ("\n");
 
265
}
 
266
   
 
267
void ShowGame (void)
 
268
{
 
269
  int i;
 
270
 
 
271
/* *********************************************
 
272
   * We must handle the special case of an EPD *
 
273
   * game where the first move is by black     *
 
274
   ********************************************* */
 
275
  
 
276
  if ( GameCnt >= 0 )
 
277
  {
 
278
  
 
279
    printf ("      White   Black\n");
 
280
  
 
281
    if ( ( board.side == white && GameCnt % 2 == 1 ) ||
 
282
         ( board.side == black && GameCnt % 2 == 0 ))
 
283
    {
 
284
    
 
285
      for (i = 0; i <= GameCnt; i += 2)
 
286
        {
 
287
          printf ("%3d.  %-7s %-7s\n", i/2 + 1, Game[i].SANmv, 
 
288
              Game[i + 1].SANmv);
 
289
        }
 
290
    }
 
291
    else {
 
292
    
 
293
      printf ("  1.          %-7s\n", Game[0].SANmv);
 
294
  
 
295
      for (i = 1; i <= GameCnt; i += 2)
 
296
        {
 
297
          printf ("%3d.  %-7s %-7s\n", i/2 + 2, Game[i].SANmv, 
 
298
              Game[i + 1].SANmv);
 
299
        }
 
300
    }
 
301
    printf ("\n");
 
302
  }
 
303
}