X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftypes.h;h=99567bd7e22a608de7ca91a16d81058112661624;hp=75dff4b8030155d57ed49cdd9af4b62cad60ee8d;hb=22c557ca7ce957cfb164c56dd149f22e2f11c7f9;hpb=e304db9d1ecf6a2318708483c90fadecf4fac4ee diff --git a/src/types.h b/src/types.h index 75dff4b8..99567bd7 100644 --- a/src/types.h +++ b/src/types.h @@ -35,6 +35,7 @@ /// | only in 64-bit mode. For compiling requires hardware with /// | popcnt support. +#include #include #include #include @@ -148,7 +149,8 @@ enum CastlingSide { enum Phase { PHASE_ENDGAME = 0, - PHASE_MIDGAME = 128 + PHASE_MIDGAME = 128, + MG = 0, EG = 1, PHASE_NB = 2 }; enum ScaleFactor { @@ -179,8 +181,6 @@ enum Value { VALUE_ENSURE_INTEGER_SIZE_P = INT_MAX, VALUE_ENSURE_INTEGER_SIZE_N = INT_MIN, - Mg = 0, Eg = 1, - PawnValueMg = 198, PawnValueEg = 258, KnightValueMg = 817, KnightValueEg = 846, BishopValueMg = 836, BishopValueEg = 857, @@ -195,7 +195,7 @@ enum PieceType { }; enum Piece { - NO_PIECE = 16, // color_of(NO_PIECE) == NO_COLOR + NO_PIECE = 0, W_PAWN = 1, W_KNIGHT = 2, W_BISHOP = 3, W_ROOK = 4, W_QUEEN = 5, W_KING = 6, B_PAWN = 9, B_KNIGHT = 10, B_BISHOP = 11, B_ROOK = 12, B_QUEEN = 13, B_KING = 14, PIECE_NB = 16 @@ -347,7 +347,7 @@ namespace Zobrist { CACHE_LINE_ALIGNMENT extern Score pieceSquareTable[PIECE_NB][SQUARE_NB]; -extern Value PieceValue[2][18]; // [Mg / Eg][piece / pieceType] +extern Value PieceValue[PHASE_NB][PIECE_NB]; extern int SquareDistance[SQUARE_NB][SQUARE_NB]; struct MoveStack { @@ -392,6 +392,7 @@ inline PieceType type_of(Piece p) { } inline Color color_of(Piece p) { + assert(p != NO_PIECE); return Color(p >> 3); } @@ -441,11 +442,11 @@ inline int square_distance(Square s1, Square s2) { } inline char file_to_char(File f) { - return char(f - FILE_A + int('a')); + return char(f - FILE_A + 'a'); } inline char rank_to_char(Rank r) { - return char(r - RANK_1 + int('1')); + return char(r - RANK_1 + '1'); } inline Square pawn_push(Color c) { @@ -491,15 +492,15 @@ inline const std::string square_to_string(Square s) { /// Our insertion sort implementation, works with pointers and iterators and is /// guaranteed to be stable, as is needed. template -void sort(K first, K last) +void sort(K begin, K end) { T tmp; K p, q; - for (p = first + 1; p < last; p++) + for (p = begin + 1; p < end; p++) { tmp = *p; - for (q = p; q != first && *(q-1) < tmp; --q) + for (q = p; q != begin && *(q-1) < tmp; --q) *q = *(q-1); *q = tmp; }