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;
28 #endif // _MSC_VER <= 1600 36 #define BBUF_SIZE 256000 //120000 59 #define ASSERT(f) assert(f) 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) 75 #define UPPER_4_BITS(x) (((x) & 240) >> 4) // 240 is (15 * 16) 76 #define LOWER_4_BITS(x) ((x) & 15) 80 #define UPPER_12_BITS(x) (((x) & (4096 * 4095)) >> 12) 81 #define LOWER_12_BITS(x) ((x) & 4095) 89 typedef unsigned char byte;
266 false,
true,
true,
true,
false,
false,
276 -100, -9, -5, -3, -3, -1,
331 case 'K':
return KING;
332 case 'Q':
return QUEEN;
333 case 'R':
return ROOK;
336 default:
return EMPTY;
370 {
if (c < '1' || c >
'8') {
return NO_RANK; }
else return (c -
'1'); }
374 {
if (c < 'a' || c >
'h') {
return NO_FYLE; }
else return (c -
'a'); }
380 return ((r << 3) | f);
392 return ((sq >> 3) & 0x7);
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
459 return (rankd > fyled) ? rankd : fyled;
477 return (sq ==
A1 || sq ==
H1 || sq ==
A8 || sq ==
H8);
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,
516 return ((rdist * fdist) == 2);
539 str[0] =
'N'; str[1] =
'S'; str[2] = 0;
541 str[0] =
'X'; str[1] =
'X'; str[2] = 0;
579 return dirOpposite[d];
665 for (
uint i=0; i < 64; i++) {
666 if (*b1 < *b2) {
return -1; }
667 if (*b1 > *b2) {
return 1; }
682 int rdist = (int)fromRank - (
int)toRank;
683 if (rdist < -1 || rdist > 1) {
return false; }
686 int fdist = (int)fromFyle - (
int)toFyle;
687 if (fdist < -1 || fdist > 1) {
return false; }
691 #endif // #ifdef SCID_COMMON_H
int piece_Value(pieceT p)
fyleT fyle_FromChar(char c)
squareT square_FlipRank(squareT sq)
const uint NUM_COLOR_TYPES
uint square_Distance(squareT from, squareT to)
const versionT SCID_OLDEST_VERSION
pieceT piece_Type(pieceT p)
const char SCID_WEBSITE[]
void square_Print(squareT sq, char *str)
bool square_IsKnightHop(squareT from, squareT to)
const compareT GREATER_THAN
const uint NUM_RESULT_TYPES
const bool PIECE_IS_SLIDER[8]
colorT square_Color(squareT sq)
const int PIECE_VALUE[MAX_PIECE_TYPES]
const squareT NULL_SQUARE
const char SCID_VERSION_STRING[]
const directionT dirOpposite[11]
const char * ratingTypeNames[17]
squareT square_FlipDiag(squareT sq)
bool piece_IsWhite(pieceT p)
const resultT RESULT_Black
const colorT BOARD_SQUARECOLOR[66]
const resultT RESULT_OPPOSITE[4]
rankT square_Rank(squareT sq)
bool piece_IsRook(pieceT p)
bool square_IsCornerSquare(squareT sq)
colorT color_Flip(colorT c)
const resultT RESULT_Draw
bool piece_IsKing(pieceT p)
squareT square_Make(fyleT f, rankT r)
const char RESULT_STR[4][4]
const pieceT PIECE_FLIP[MAX_PIECE_TYPES]
const directionT UP_RIGHT
const pieceT INVALID_PIECE
const bool dirIsDiagonal[11]
const resultT RESULT_White
const uint MAX_PIECE_TYPES
int direction_Delta(directionT dir)
rightDiagT square_RightDiag(squareT sq)
rankT rank_FromChar(char c)
squareT square_FlipFyle(squareT sq)
const char RESULT_CHAR[4]
squareT square_NearestCorner(squareT sq)
bool piece_IsQueen(pieceT p)
const directionT NULL_DIR
bool square_IsEdgeSquare(squareT sq)
pieceT piece_FromChar(int x)
leftDiagT square_LeftDiag(squareT sq)
char square_FyleChar(squareT sq)
bool piece_IsPawn(pieceT p)
const uint RESULT_SCORE[4]
colorT piece_Color(pieceT p)
bool piece_IsBishop(pieceT p)
directionT direction_Opposite(directionT d)
const char RESULT_LONGSTR[4][8]
const pieceT END_OF_BOARD
bool piece_IsBlack(pieceT p)
const uint rankFyleDist[64]
colorT piece_Color_NotEmpty(pieceT p)
bool direction_IsDiagonal(directionT dir)
int board_Compare(const pieceT *b1, const pieceT *b2)
bool piece_IsKnight(pieceT p)
bool square_Adjacent(squareT from, squareT to)
const versionT SCID_VERSION
const directionT DOWN_RIGHT
const squareT COLOR_SQUARE
char color_Char(colorT c)
const resultT RESULT_None
int square_EdgeDistance(squareT sq)
pieceT piece_Make(colorT c, pieceT p)
char square_RankChar(squareT sq)
const directionT DOWN_LEFT
char piece_Char(pieceT p)
fyleT square_Fyle(squareT sq)
bool piece_IsSlider(pieceT p)