Scid  4.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
common.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////
2 //
3 // FILE: common.h
4 // Common macros, structures and constants.
5 //
6 // Part of: Scid (Shane's Chess Information Database)
7 // Version: 3.6.6
8 //
9 // Notice: Copyright (c) 2000-2004 Shane Hudson. All rights reserved.
10 //
11 // Author: Shane Hudson (sgh@users.sourceforge.net)
12 // Copyright (c) 2006-2007 Pascal Georges
13 //
14 //////////////////////////////////////////////////////////////////////
15 
16 #ifndef SCID_COMMON_H
17 #define SCID_COMMON_H
18 
19 #include <cstddef>
20 #if defined(_MSC_VER) && _MSC_VER <= 1600
21 typedef unsigned __int8 uint8_t;
22 typedef unsigned __int16 uint16_t;
23 typedef unsigned __int32 uint32_t;
24 typedef unsigned __int64 uint64_t;
25 typedef __int32 int32_t;
26 #else
27 #include <stdint.h>
28 #endif // _MSC_VER <= 1600
29 
30 #include "error.h"
31 
32 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33 // CONSTANTS:
34 
35 // Buffer sizes
36 #define BBUF_SIZE 256000 //120000
37 
38 typedef unsigned short versionT;
39 
40 // Version: div by 100 for major number, modulo 100 for minor number
41 // so 109 = 1.9, 110 = 1.10, etc.
42 
43 const versionT SCID_VERSION = 400; // Current file format version = 4.0
44 const versionT SCID_OLDEST_VERSION = 300; // Oldest readable file format: 3.0
45 
46 const char SCID_VERSION_STRING[] = "4.7.0"; // Current Scid version
47 const char SCID_WEBSITE[] = "http://scid.sourceforge.net/";
48 
49 const char PGN_SUFFIX[] = ".pgn";
50 
51 
52 //////////////////////////////////////////////////////////////////////
53 // ASSERT macro: asserts an expression. Differs from the standard
54 // assert in that it does NOT print the expression (this is a waste,
55 // if an assert fails you can go to the code to see why) and that
56 // it MUST be a statement, not part of a larger expression.
57 // Adapted from the book "Writing Solid Code".
58 #include <assert.h>
59 #define ASSERT(f) assert(f)
60 
61 
62 // Bit Manipulations
63 
64 #define BIT_7(x) ((x) & 128)
65 #define BIT_6(x) ((x) & 64)
66 #define BIT_5(x) ((x) & 32)
67 #define BIT_4(x) ((x) & 16)
68 #define BIT_3(x) ((x) & 8)
69 #define BIT_2(x) ((x) & 4)
70 #define BIT_1(x) ((x) & 2)
71 #define BIT_0(x) ((x) & 1)
72 
73 // Upper or lower 4 bits of a byte, in the range 0..15
74 
75 #define UPPER_4_BITS(x) (((x) & 240) >> 4) // 240 is (15 * 16)
76 #define LOWER_4_BITS(x) ((x) & 15)
77 
78 // Upper or lower 12 bits of an integer, in the range 0..4095
79 //
80 #define UPPER_12_BITS(x) (((x) & (4096 * 4095)) >> 12)
81 #define LOWER_12_BITS(x) ((x) & 4095)
82 
83 
84 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85 // TYPE DEFINITIONS
86 
87 // General types
88 
89 typedef unsigned char byte; // 8 bit unsigned
90 typedef uint16_t ushort; // 16 bit unsigned
91 typedef uint32_t uint; // 32 bit unsigned
92 typedef int32_t sint; // 32 bit signed
93 
94 
95 // compareT: comparison type
96 
97 typedef signed int compareT;
98 const compareT
100 
101 // Chess Types
102 
103 typedef byte pieceT; // e.g ROOK or WK
104 typedef byte colorT; // WHITE or BLACK
105 typedef byte squareT; // e.g. A3
106 typedef byte directionT; // e.g. UP_LEFT
107 typedef byte rankT; // Chess board rank
108 typedef byte fyleT; // Chess board file
109 typedef byte leftDiagT; // Up-left diagonals
110 typedef byte rightDiagT; // Up-right diagonals
111 
112 // boardT: 64 squares plus two extra squares: one for storing the side
113 // to move as a byte and one for the string terminator, so boards can
114 // be compared using regular string functions:
115 typedef pieceT boardT [66];
116 
117 typedef byte smallBoardT [32];
118  // A more densely packed board, 2 squares
119  // per byte.
120 
121 typedef byte castleDirT; // LEFT or RIGHT
122 
123 // Other Small Types
124 
125 typedef ushort statusT;
126 
127 // Fixed String Types
128 
129 typedef char sanStringT [ 10]; // SAN Move Notation
130 
131 // File-related Types
132 
133 typedef char fileNameT [512];
135 
136 enum fileModeT {
143 };
144 
145 // Date type: see date.h and date.cpp
146 
147 typedef uint dateT;
148 
149 
150 // There are four name types: PLAYER, EVENT, SITE and ROUND tags.
151 // Names are accessed through IDs.
152 typedef uint32_t idNumberT; // Should be idNameT
153 typedef unsigned nameT;
154 enum {
158 };
159 
160 
161 // Game Information types
162 
163 typedef uint gamenumT;
164 typedef ushort eloT;
165 typedef ushort ecoT;
166 typedef char ecoStringT [6]; /* "A00j1" */
167 
168 const ecoT ECO_None = 0;
169 
170 // Rating types:
171 
172 const byte RATING_Elo = 0;
173 const byte RATING_Rating = 1;
174 const byte RATING_Rapid = 2;
175 const byte RATING_ICCF = 3;
176 const byte RATING_USCF = 4;
177 const byte RATING_DWZ = 5;
178 const byte RATING_BCF = 6;
179 
180 extern const char * ratingTypeNames [17]; // Defined in game.cpp
181 
182 
183 
184 // Result Type
185 
187 typedef byte resultT;
188 const resultT
193 
194 const uint RESULT_SCORE[4] = { 1, 2, 0, 1 };
195 const char RESULT_CHAR [4] = { '*', '1', '0', '=' };
196 const char RESULT_STR [4][4] = { "*", "1-0", "0-1", "=-=" };
197 const char RESULT_LONGSTR [4][8] = { "*", "1-0", "0-1", "1/2-1/2" };
200 };
201 
202 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203 // CHESS PIECES, COLORS AND THEIR MACROS
204 
206 const colorT
207  WHITE = 0,
208  BLACK = 1,
209  NOCOLOR = 2;
210 
211 const char COLOR_CHAR [3] = {'W', 'B', '_' };
212 
213  inline colorT
214 color_Flip (colorT c) { return 1 - c; }
215 
216  inline char
217 color_Char(colorT c) { return COLOR_CHAR[c]; }
218 
219 const castleDirT QSIDE = 0, KSIDE = 1;
220 
221 
222 // PIECE TYPES (without color; same value as a white piece)
223 
224 const pieceT
226  KING = 1,
227  QUEEN = 2,
228  ROOK = 3,
229  BISHOP = 4,
230  KNIGHT = 5,
231  PAWN = 6;
232 
233 // PIECES:
234 // Note that color(x) == ((x & 0x8) >> 3) and type(x) == (x & 0x7)
235 // EMPTY is deliberately nonzero, and END_OF_BOARD is zero, so that
236 // a board can be used as a regular 0-terminated string, provided
237 // that board[NULL_SQUARE] == END_OF_BOARD, as it always should be.
238 
239 const pieceT EMPTY = 7;
241 const pieceT WK = 1, WQ = 2, WR = 3, WB = 4, WN = 5, WP = 6;
242 const pieceT BK = 9, BQ = 10, BR = 11, BB = 12, BN = 13, BP = 14;
243 
244 // Minor piece definitions, used for searching by material only:
245 const pieceT WM = 16, BM = 17;
246 
248 
249 
250 // PIECE_CHAR[]: array of piece characters, capitals for White pieces.
251 
252 const char PIECE_CHAR [] = "xKQRBNP.xkqrbnpxMm";
253 
254 // PIECE_FLIP[]: array of pieces, with colors reversed.
255 
257  END_OF_BOARD,
258  BK, BQ, BR, BB, BN, BP,
259  EMPTY, EMPTY,
260  WK, WQ, WR, WB, WN, WP,
261  EMPTY, BM, WM
262 };
263 
264 const bool PIECE_IS_SLIDER [8] = {
265  false,
266  false, true, true, true, false, false,
267  false,
268 };
269 
270 // PIECE_VALUE: Piece values, K=1000, Q=9, R=5, B=N=3, P=1
271 
273  0,
274  100, 9, 5, 3, 3, 1,
275  0, 0,
276  -100, -9, -5, -3, -3, -1,
277  0, 3, -3
278 };
279 
280 //
281 // INLINE FUNCTIONS for pieces
282 //
283 
284  inline colorT
285 piece_Color(pieceT p) { return (p == EMPTY) ? NOCOLOR : ((p & 8) >> 3); }
286 
287 // Slightly faster piece_Color when we are sure the piece is not empty:
288  inline colorT
289 piece_Color_NotEmpty(pieceT p) { return (p & 8) >> 3; }
290 
291  inline pieceT
292 piece_Type(pieceT p) { return (p & 7); }
293 
294  inline pieceT
295 piece_Make(colorT c, pieceT p) { return ((c << 3) | (p & 7)); }
296 
297  inline bool
298 piece_IsWhite(pieceT p) { return (p>=WK && p<=WP); }
299 
300  inline bool
301 piece_IsBlack(pieceT p) { return (p>=BK && p<=BP); }
302 
303  inline bool
304 piece_IsKing(pieceT p) { return (piece_Type(p) == KING); }
305 
306  inline bool
307 piece_IsQueen(pieceT p) { return (piece_Type(p) == QUEEN); }
308 
309  inline bool
310 piece_IsRook(pieceT p) { return (piece_Type(p) == ROOK); }
311 
312  inline bool
313 piece_IsBishop(pieceT p) { return (piece_Type(p) == BISHOP); }
314 
315  inline bool
316 piece_IsKnight(pieceT p) { return (piece_Type(p) == KNIGHT); }
317 
318  inline bool
319 piece_IsPawn(pieceT p) { return (piece_Type(p) == PAWN); }
320 
321  inline bool
323 
324  inline char
326 
327  inline pieceT
329 {
330  switch (x) {
331  case 'K': return KING;
332  case 'Q': return QUEEN;
333  case 'R': return ROOK;
334  case 'N': return KNIGHT;
335  case 'B': return BISHOP;
336  default: return EMPTY;
337  }
338 }
339 
340 inline int
341 piece_Value (pieceT p) { return PIECE_VALUE[p]; }
342 
343 
344 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
345 // SQUARES AND SQUARE MACROS
346 
347 const squareT
348  A1 = 0, B1 = 1, C1 = 2, D1 = 3, E1 = 4, F1 = 5, G1 = 6, H1 = 7,
349  A2 = 8, B2 = 9, C2 =10, D2 =11, E2 =12, F2 =13, G2 =14, H2 =15,
350  A3 =16, B3 =17, C3 =18, D3 =19, E3 =20, F3 =21, G3 =22, H3 =23,
351  A4 =24, B4 =25, C4 =26, D4 =27, E4 =28, F4 =29, G4 =30, H4 =31,
352  A5 =32, B5 =33, C5 =34, D5 =35, E5 =36, F5 =37, G5 =38, H5 =39,
353  A6 =40, B6 =41, C6 =42, D6 =43, E6 =44, F6 =45, G6 =46, H6 =47,
354  A7 =48, B7 =49, C7 =50, D7 =51, E7 =52, F7 =53, G7 =54, H7 =55,
355  A8 =56, B8 =57, C8 =58, D8 =59, E8 =60, F8 =61, G8 =62, H8 =63,
357  NULL_SQUARE = 65, NS = 65; // NS is abbreviation for NULL_SQUARE.
358 
359 const rankT
360  RANK_1 = 0, RANK_2 = 1, RANK_3 = 2, RANK_4 = 3, RANK_5 = 4, RANK_6 = 5,
361  RANK_7 = 6, RANK_8 = 7, NO_RANK = 64;
362 
363 const fyleT
364  // we use "fyle" instead of "file" to avoid confusion with disk files.
365  A_FYLE = 0, B_FYLE = 1, C_FYLE = 2, D_FYLE = 3, E_FYLE = 4, F_FYLE = 5,
366  G_FYLE = 6, H_FYLE = 7, NO_FYLE = 64;
367 
368  inline rankT
370 { if (c < '1' || c > '8') { return NO_RANK; } else return (c - '1'); }
371 
372  inline fyleT
374 { if (c < 'a' || c > 'h') { return NO_FYLE; } else return (c - 'a'); }
375 
376  inline squareT
378 {
379  ASSERT (f <= H_FYLE && r <= RANK_8);
380  return ((r << 3) | f);
381 }
382 
383  inline fyleT
385 {
386  return (sq & 0x7);
387 }
388 
389  inline rankT
391 {
392  return ((sq >> 3) & 0x7);
393 }
394 
395  inline leftDiagT
397 {
398  return square_Rank(sq) + square_Fyle(sq);
399 }
400 
401  inline rightDiagT
403 {
404  return (7 + square_Rank(sq) - square_Fyle(sq));
405 }
406 
407 // square_Color:
408 // Return WHITE for a light square, BLACK for a dark square.
409  inline colorT
411 {
412  return 1 - (square_LeftDiag(sq) & 1);
413 }
414 
415 // square_FlipFyle:
416 // Return the square with its file flipped: a1 <-> h1, b1 <-> g1, etc.
417  inline squareT
419 {
420  return square_Make (A_FYLE + H_FYLE - square_Fyle(sq), square_Rank(sq));
421 }
422 
423 // square_FlipRank:
424 // Return the square with its rank flipped: a1 <-> a8, a2 <-> a7, etc.
425  inline squareT
427 {
428  return square_Make (square_Fyle(sq), RANK_1 + RANK_8 - square_Rank(sq));
429 }
430 
431 // square_FlipDiag:
432 // Return the square flipped along the a1-h8 diagonal.
433  inline squareT
435 {
436  return square_Make (square_Rank(sq), square_Fyle(sq));
437 }
438 
439 const uint
441  0, 1, 2, 3, 4, 5, 6, 7,
442  1, 0, 1, 2, 3, 4, 5, 6,
443  2, 1, 0, 1, 2, 3, 4, 5,
444  3, 2, 1, 0, 1, 2, 3, 4,
445  4, 3, 2, 1, 0, 1, 2, 3,
446  5, 4, 3, 2, 1, 0, 1, 2,
447  6, 5, 4, 3, 2, 1, 0, 1,
448  7, 6, 5, 4, 3, 2, 1, 0
449 };
450 
451 // square_Distance:
452 // Return the distance in king moves between two squares.
453  inline uint
455 {
456  ASSERT (from <= H8 && to <= H8);
457  uint rankd = rankFyleDist[(square_Rank(from) << 3) | square_Rank(to)];
458  uint fyled = rankFyleDist[(square_Fyle(from) << 3) | square_Fyle(to)];
459  return (rankd > fyled) ? rankd : fyled;
460 }
461 
462 // square_NearestCorner:
463 // Return the corner (A1/H1/A8/H8) closest to the specified square.
464  inline squareT
466 {
467  if (square_Rank(sq) <= RANK_4) {
468  return (square_Fyle(sq) <= D_FYLE)? A1 : H1;
469  } else {
470  return (square_Fyle(sq) <= D_FYLE)? A8 : H8;
471  }
472 }
473 
474  inline bool
476 {
477  return (sq == A1 || sq == H1 || sq == A8 || sq == H8);
478 }
479 
480  inline bool
482 {
483  rankT rank = square_Rank(sq);
484  if (rank == RANK_1 || rank == RANK_8) { return true; }
485  fyleT fyle = square_Fyle(sq);
486  if (fyle == A_FYLE || fyle == H_FYLE) { return true; }
487  return false;
488 }
489 
490 const int edgeDist[66] = {
491  0, 0, 0, 0, 0, 0, 0, 0,
492  0, 1, 1, 1, 1, 1, 1, 0,
493  0, 1, 2, 2, 2, 2, 1, 0,
494  0, 1, 2, 3, 3, 2, 1, 0,
495  0, 1, 2, 3, 3, 2, 1, 0,
496  0, 1, 2, 2, 2, 2, 1, 0,
497  0, 1, 1, 1, 1, 1, 1, 0,
498  0, 0, 0, 0, 0, 0, 0, 0,
499  -1, -1
500 };
501 
502  inline int
504 {
505  return edgeDist[sq];
506 }
507 
508  inline bool
510 {
511  ASSERT (from <= H8 && to <= H8);
512  uint rdist = rankFyleDist [(square_Rank(from) << 3) | square_Rank(to)];
513  uint fdist = rankFyleDist [(square_Fyle(from) << 3) | square_Fyle(to)];
514  // It is a knight hop only if one distance is two squares and the
515  // other is one square -- that is, only if their product equals two.
516  return ((rdist * fdist) == 2);
517 }
518 
519  inline char
521 {
522  return square_Fyle(sq) + 'a';
523 }
524 
525  inline char
527 {
528  return square_Rank(sq) + '1';
529 }
530 
531  inline void
532 square_Print (squareT sq, char * str)
533 {
534  if (sq <= H8) {
535  str[0] = square_FyleChar(sq);
536  str[1] = square_RankChar(sq);
537  str[2] = 0;
538  } else if (sq == NULL_SQUARE) {
539  str[0] = 'N'; str[1] = 'S'; str[2] = 0;
540  } else {
541  str[0] = 'X'; str[1] = 'X'; str[2] = 0;
542  }
543  return;
544 }
545 
546 // Directions:
547 // Up = 1, Down = 2, Left = 4, Right = 8, UpLeft = 5, UpRight = 9,
548 // DownLeft = 6, DownRight = 10
549 
550 const directionT
551  NULL_DIR = 0,
552  UP = 1,
553  DOWN = 2,
554  LEFT = 4,
555  RIGHT = 8,
556  UP_LEFT = (UP | LEFT),
560 
561 const directionT dirOpposite[11] = {
562  NULL_DIR,
563  DOWN, // opposite of UP (1)
564  UP, // opposite of DOWN (2)
565  NULL_DIR,
566  RIGHT, // opposite of LEFT (4)
567  DOWN_RIGHT, // opposite of UP_LEFT (5)
568  UP_RIGHT, // opposite of DOWN_LEFT (6)
569  NULL_DIR,
570  LEFT, // opposite of RIGHT (8)
571  DOWN_LEFT, // opposite of UP_RIGHT (9)
572  UP_LEFT // opposite of DOWN_RIGHT (10)
573 };
574 
575 // direction_Opposite(): return the opposite direction to d
576  inline directionT
578 {
579  return dirOpposite[d];
580 }
581 
582 // dirIsDiagonal[]: array listing the diagonal directions, for fast
583 // lookup of whether a direction is a diagonal.
584  const bool
586  false, // 0 = NULL_DIR
587  false, // 1 = UP
588  false, // 2 = DOWN
589  false, // 3 = Invalid
590  false, // 4 = LEFT
591  true, // 5 = UP_LEFT
592  true, // 6 = DOWN_LEFT
593  false, // 7 = Invalid
594  false, // 8 = RIGHT
595  true, // 9 = UP_RIGHT
596  true // 10 = DOWN_RIGHT
597 };
598 
599  inline bool
601 {
602  return dirIsDiagonal[dir];
603 }
604 
605 // dirDelta:
606 // Array giving the board delta of moving to the next square
607 // in that direction.
608  const int
609 dirDelta[11] = {
610  0, // NULL_DIR
611  8, // UP
612  -8, // DOWN
613  0, // Invalid
614  -1, // LEFT
615  7, // UP_LEFT
616  -9, // DOWN_LEFT
617  0, // Invalid
618  1, // RIGHT
619  9, // UP_RIGHT
620  -7 // DOWN_RIGHT
621 };
622 
623  inline int
625 {
626  return dirDelta[dir];
627 }
628 
629 // The starting Board
630 //
631  const boardT
633 {
634  WR, WN, WB, WQ, WK, WB, WN, WR, // A1--H1
635  WP, WP, WP, WP, WP, WP, WP, WP, // A2--H2
640  BP, BP, BP, BP, BP, BP, BP, BP,
641  BR, BN, BB, BQ, BK, BB, BN, BR,
642  EMPTY, // COLOR_SQUARE
643  END_OF_BOARD // NULL_SQUARE
644 };
645 
646 
647 // Square colors for the standard chess board:
648 //
649  const colorT
651  BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, // a1-h1
652  WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, // a2-h2
653  BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, // a3-h3
654  WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, // a4-h4
655  BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, // a5-h5
656  WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, // a6-h6
657  BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, // a7-h7
658  WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, WHITE, BLACK, // a8-h8
659  NOCOLOR, NOCOLOR // Color square and Null square
660 };
661 
662  inline int
663 board_Compare (const pieceT * b1, const pieceT * b2)
664 {
665  for (uint i=0; i < 64; i++) {
666  if (*b1 < *b2) { return -1; }
667  if (*b1 > *b2) { return 1; }
668  b1++; b2++;
669  }
670  return 0;
671 }
672 
673 // square_Adjacent: returns 1 if the two squares are adjacent. Note that
674 // diagonal adjacency is included: a1 and b2 are adjacent.
675 // Also note that a square is adjacent to itself.
676  inline bool
678 {
679  ASSERT (from <= H8 && to <= H8);
680  rankT fromRank = square_Rank(from);
681  rankT toRank = square_Rank(to);
682  int rdist = (int)fromRank - (int)toRank;
683  if (rdist < -1 || rdist > 1) { return false; }
684  fyleT fromFyle = square_Fyle(from);
685  fyleT toFyle = square_Fyle(to);
686  int fdist = (int)fromFyle - (int)toFyle;
687  if (fdist < -1 || fdist > 1) { return false; }
688  return true;
689 }
690 
691 #endif // #ifdef SCID_COMMON_H
692 
693 //////////////////////////////////////////////////////////////////////
694 // EOF: common.h
695 //////////////////////////////////////////////////////////////////////
696 
const pieceT WK
Definition: common.h:241
unsigned char byte
Definition: common.h:89
int piece_Value(pieceT p)
Definition: common.h:341
fyleT fyle_FromChar(char c)
Definition: common.h:373
squareT square_FlipRank(squareT sq)
Definition: common.h:426
const squareT F5
Definition: common.h:352
const squareT F2
Definition: common.h:349
const uint NUM_COLOR_TYPES
Definition: common.h:205
byte resultT
Definition: common.h:187
const pieceT BB
Definition: common.h:242
uint square_Distance(squareT from, squareT to)
Definition: common.h:454
const versionT SCID_OLDEST_VERSION
Definition: common.h:44
const squareT C5
Definition: common.h:352
const squareT C4
Definition: common.h:351
const colorT WHITE
Definition: common.h:207
pieceT piece_Type(pieceT p)
Definition: common.h:292
const char SCID_WEBSITE[]
Definition: common.h:47
const squareT C8
Definition: common.h:355
const pieceT BK
Definition: common.h:242
sqsqname
Definition: board.tcl:292
const pieceT BN
Definition: common.h:242
const squareT B3
Definition: common.h:350
const directionT UP
Definition: common.h:552
void square_Print(squareT sq, char *str)
Definition: common.h:532
const castleDirT KSIDE
Definition: common.h:219
bool square_IsKnightHop(squareT from, squareT to)
Definition: common.h:509
const compareT GREATER_THAN
Definition: common.h:99
const squareT F4
Definition: common.h:351
const byte RATING_Rapid
Definition: common.h:174
const uint NUM_RESULT_TYPES
Definition: common.h:186
const fyleT D_FYLE
Definition: common.h:365
const squareT F8
Definition: common.h:355
const bool PIECE_IS_SLIDER[8]
Definition: common.h:264
colorT square_Color(squareT sq)
Definition: common.h:410
const squareT H1
Definition: common.h:348
unsigned short versionT
Definition: common.h:38
const int PIECE_VALUE[MAX_PIECE_TYPES]
Definition: common.h:272
const fyleT G_FYLE
Definition: common.h:366
const squareT NULL_SQUARE
Definition: common.h:357
const ecoT ECO_None
Definition: common.h:168
const colorT NOCOLOR
Definition: common.h:209
const squareT A4
Definition: common.h:351
byte rankT
Definition: common.h:107
const squareT D2
Definition: common.h:349
const directionT LEFT
Definition: common.h:554
const rankT NO_RANK
Definition: common.h:361
const byte RATING_BCF
Definition: common.h:178
const squareT G6
Definition: common.h:353
const rankT RANK_2
Definition: common.h:360
uint dateT
Definition: common.h:147
#define ASSERT(f)
Definition: common.h:59
const char SCID_VERSION_STRING[]
Definition: common.h:46
const squareT H7
Definition: common.h:354
const directionT dirOpposite[11]
Definition: common.h:561
const squareT C1
Definition: common.h:348
const rankT RANK_8
Definition: common.h:361
const char * ratingTypeNames[17]
Definition: game.cpp:71
const fyleT B_FYLE
Definition: common.h:365
const directionT UP_LEFT
Definition: common.h:556
const pieceT BQ
Definition: common.h:242
const byte RATING_DWZ
Definition: common.h:177
squareT square_FlipDiag(squareT sq)
Definition: common.h:434
const squareT H4
Definition: common.h:351
bool piece_IsWhite(pieceT p)
Definition: common.h:298
const pieceT WQ
Definition: common.h:241
const pieceT KING
Definition: common.h:226
const resultT RESULT_Black
Definition: common.h:191
const rankT RANK_3
Definition: common.h:360
const squareT B5
Definition: common.h:352
const colorT BOARD_SQUARECOLOR[66]
Definition: common.h:650
const pieceT BP
Definition: common.h:242
const colorT BLACK
Definition: common.h:208
const resultT RESULT_OPPOSITE[4]
Definition: common.h:198
const squareT E7
Definition: common.h:354
rankT square_Rank(squareT sq)
Definition: common.h:390
byte fyleT
Definition: common.h:108
const fyleT H_FYLE
Definition: common.h:366
bool piece_IsRook(pieceT p)
Definition: common.h:310
ushort statusT
Definition: common.h:125
char ecoStringT[6]
Definition: common.h:166
const squareT G5
Definition: common.h:352
bool square_IsCornerSquare(squareT sq)
Definition: common.h:475
const squareT D7
Definition: common.h:354
const fyleT C_FYLE
Definition: common.h:365
const squareT A8
Definition: common.h:355
colorT color_Flip(colorT c)
Definition: common.h:214
const squareT E6
Definition: common.h:353
const compareT LESS_THAN
Definition: common.h:99
const fyleT NO_FYLE
Definition: common.h:366
const resultT RESULT_Draw
Definition: common.h:192
bool piece_IsKing(pieceT p)
Definition: common.h:304
uint32_t idNumberT
Definition: common.h:152
const directionT RIGHT
Definition: common.h:555
int32_t sint
Definition: common.h:92
const squareT H6
Definition: common.h:353
const pieceT BISHOP
Definition: common.h:229
const squareT A1
Definition: common.h:348
const pieceT KNIGHT
Definition: common.h:230
squareT square_Make(fyleT f, rankT r)
Definition: common.h:377
const squareT A7
Definition: common.h:354
const char RESULT_STR[4][4]
Definition: common.h:196
const byte RATING_USCF
Definition: common.h:176
byte smallBoardT[32]
Definition: common.h:117
const squareT B4
Definition: common.h:351
const int edgeDist[66]
Definition: common.h:490
const pieceT PIECE_FLIP[MAX_PIECE_TYPES]
Definition: common.h:256
const squareT A6
Definition: common.h:353
const directionT UP_RIGHT
Definition: common.h:557
const castleDirT QSIDE
Definition: common.h:219
const pieceT EMPTY
Definition: common.h:239
const squareT F6
Definition: common.h:353
const pieceT INVALID_PIECE
Definition: common.h:225
const pieceT WB
Definition: common.h:241
const squareT G1
Definition: common.h:348
const squareT F7
Definition: common.h:354
const squareT H3
Definition: common.h:350
const bool dirIsDiagonal[11]
Definition: common.h:585
const fyleT E_FYLE
Definition: common.h:365
const pieceT QUEEN
Definition: common.h:227
const resultT RESULT_White
Definition: common.h:190
uint32_t uint
Definition: common.h:91
const uint MAX_PIECE_TYPES
Definition: common.h:247
const squareT H2
Definition: common.h:349
int direction_Delta(directionT dir)
Definition: common.h:624
const byte RATING_ICCF
Definition: common.h:175
const squareT B2
Definition: common.h:349
const squareT C2
Definition: common.h:349
const pieceT ROOK
Definition: common.h:228
rightDiagT square_RightDiag(squareT sq)
Definition: common.h:402
rankT rank_FromChar(char c)
Definition: common.h:369
squareT square_FlipFyle(squareT sq)
Definition: common.h:418
const char RESULT_CHAR[4]
Definition: common.h:195
const squareT H5
Definition: common.h:352
pieceT boardT[66]
Definition: common.h:115
const squareT H8
Definition: common.h:355
const rankT RANK_5
Definition: common.h:360
byte rightDiagT
Definition: common.h:110
const squareT A3
Definition: common.h:350
const squareT B1
Definition: common.h:348
squareT square_NearestCorner(squareT sq)
Definition: common.h:465
ushort eloT
Definition: common.h:164
const pieceT PAWN
Definition: common.h:231
const squareT G8
Definition: common.h:355
const squareT G7
Definition: common.h:354
bool piece_IsQueen(pieceT p)
Definition: common.h:307
ushort ecoT
Definition: common.h:165
const squareT D1
Definition: common.h:348
const squareT B8
Definition: common.h:355
const directionT NULL_DIR
Definition: common.h:551
signed int compareT
Definition: common.h:97
bool square_IsEdgeSquare(squareT sq)
Definition: common.h:481
const boardT START_BOARD
Definition: common.h:632
pieceT piece_FromChar(int x)
Definition: common.h:328
leftDiagT square_LeftDiag(squareT sq)
Definition: common.h:396
char square_FyleChar(squareT sq)
Definition: common.h:520
const char COLOR_CHAR[3]
Definition: common.h:211
const pieceT WM
Definition: common.h:245
const squareT B7
Definition: common.h:354
const char PGN_SUFFIX[]
Definition: common.h:49
uint fileLengthT
Definition: common.h:134
const byte RATING_Elo
Definition: common.h:172
const squareT E5
Definition: common.h:352
const squareT C6
Definition: common.h:353
const squareT D6
Definition: common.h:353
bool piece_IsPawn(pieceT p)
Definition: common.h:319
uint16_t ushort
Definition: common.h:90
const uint RESULT_SCORE[4]
Definition: common.h:194
const squareT G3
Definition: common.h:350
colorT piece_Color(pieceT p)
Definition: common.h:285
const pieceT WP
Definition: common.h:241
const squareT E2
Definition: common.h:349
bool piece_IsBishop(pieceT p)
Definition: common.h:313
directionT direction_Opposite(directionT d)
Definition: common.h:577
const char RESULT_LONGSTR[4][8]
Definition: common.h:197
const directionT DOWN
Definition: common.h:553
const squareT A2
Definition: common.h:349
const pieceT END_OF_BOARD
Definition: common.h:240
const squareT E8
Definition: common.h:355
bool piece_IsBlack(pieceT p)
Definition: common.h:301
const squareT D3
Definition: common.h:350
const squareT D4
Definition: common.h:351
const rankT RANK_6
Definition: common.h:360
const uint rankFyleDist[64]
Definition: common.h:440
colorT piece_Color_NotEmpty(pieceT p)
Definition: common.h:289
char fileNameT[512]
Definition: common.h:133
bool direction_IsDiagonal(directionT dir)
Definition: common.h:600
int board_Compare(const pieceT *b1, const pieceT *b2)
Definition: common.h:663
const squareT E3
Definition: common.h:350
byte colorT
Definition: common.h:104
const compareT EQUAL_TO
Definition: common.h:99
char sanStringT[10]
Definition: common.h:129
const char PIECE_CHAR[]
Definition: common.h:252
const squareT B6
Definition: common.h:353
const pieceT BR
Definition: common.h:242
unsigned nameT
Definition: common.h:153
const squareT F3
Definition: common.h:350
const int dirDelta[11]
Definition: common.h:609
const pieceT WN
Definition: common.h:241
byte directionT
Definition: common.h:106
const squareT E1
Definition: common.h:348
const squareT D5
Definition: common.h:352
bool piece_IsKnight(pieceT p)
Definition: common.h:316
const squareT G4
Definition: common.h:351
bool square_Adjacent(squareT from, squareT to)
Definition: common.h:677
byte leftDiagT
Definition: common.h:109
uint gamenumT
Definition: common.h:163
const versionT SCID_VERSION
Definition: common.h:43
const directionT DOWN_RIGHT
Definition: common.h:559
const rankT RANK_1
Definition: common.h:360
const squareT COLOR_SQUARE
Definition: common.h:356
fileModeT
Definition: common.h:136
const pieceT BM
Definition: common.h:245
char color_Char(colorT c)
Definition: common.h:217
const resultT RESULT_None
Definition: common.h:189
const squareT E4
Definition: common.h:351
const squareT G2
Definition: common.h:349
const fyleT A_FYLE
Definition: common.h:365
const rankT RANK_4
Definition: common.h:360
const squareT A5
Definition: common.h:352
const rankT RANK_7
Definition: common.h:361
const squareT C3
Definition: common.h:350
int square_EdgeDistance(squareT sq)
Definition: common.h:503
const squareT NS
Definition: common.h:357
const squareT F1
Definition: common.h:348
const squareT C7
Definition: common.h:354
pieceT piece_Make(colorT c, pieceT p)
Definition: common.h:295
char square_RankChar(squareT sq)
Definition: common.h:526
const directionT DOWN_LEFT
Definition: common.h:558
const fyleT F_FYLE
Definition: common.h:365
char piece_Char(pieceT p)
Definition: common.h:325
byte squareT
Definition: common.h:105
const squareT D8
Definition: common.h:355
byte pieceT
Definition: common.h:103
byte castleDirT
Definition: common.h:121
fyleT square_Fyle(squareT sq)
Definition: common.h:384
const pieceT WR
Definition: common.h:241
const byte RATING_Rating
Definition: common.h:173
bool piece_IsSlider(pieceT p)
Definition: common.h:322