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