Bitboard dcCandidates;
Bitboard pinned;
- Bitboard checkSq[8];
+ Bitboard checkSq[PIECE_TYPE_NB];
Square ksq;
};
struct StateInfo {
Key pawnKey, materialKey;
- Value npMaterial[2];
+ Value npMaterial[COLOR_NB];
int castleRights, rule50, pliesFromNull;
Score psqScore;
Square epSquare;
struct ReducedStateInfo {
Key pawnKey, materialKey;
- Value npMaterial[2];
+ Value npMaterial[COLOR_NB];
int castleRights, rule50, pliesFromNull;
Score psqScore;
Square epSquare;
class Position {
public:
Position() {}
- Position(const Position& p) { *this = p; }
Position(const Position& p, Thread* t) { *this = p; thisThread = t; }
Position(const std::string& f, bool c960, Thread* t) { from_fen(f, c960, t); }
- void operator=(const Position&);
+ Position& operator=(const Position&);
// Text input/output
void from_fen(const std::string& fen, bool isChess960, Thread* th);
Thread* this_thread() const;
int64_t nodes_searched() const;
void set_nodes_searched(int64_t n);
- template<bool SkipRepetition> bool is_draw() const;
+ template<bool SkipRepetition, bool SkipThreeFoldCheck> bool is_draw() const;
// Position consistency check, for debugging
bool pos_is_ok(int* failedStep = NULL) const;
void flip();
- // Global initialization
- static void init();
-
private:
// Initialization helpers (used while setting up a position)
void clear();
Value compute_non_pawn_material(Color c) const;
// Board and pieces
- Piece board[64]; // [square]
- Bitboard byTypeBB[8]; // [pieceType]
- Bitboard byColorBB[2]; // [color]
- int pieceCount[2][8]; // [color][pieceType]
- Square pieceList[2][8][16]; // [color][pieceType][index]
- int index[64]; // [square]
+ Piece board[SQUARE_NB];
+ Bitboard byTypeBB[PIECE_TYPE_NB];
+ Bitboard byColorBB[COLOR_NB];
+ int pieceCount[COLOR_NB][PIECE_TYPE_NB];
+ Square pieceList[COLOR_NB][PIECE_TYPE_NB][16];
+ int index[SQUARE_NB];
// Other info
- int castleRightsMask[64]; // [square]
- Square castleRookSquare[2][2]; // [color][side]
- Bitboard castlePath[2][2]; // [color][side]
+ int castleRightsMask[SQUARE_NB];
+ Square castleRookSquare[COLOR_NB][CASTLING_SIDE_NB];
+ Bitboard castlePath[COLOR_NB][CASTLING_SIDE_NB];
StateInfo startState;
int64_t nodes;
int startPosPly;
Thread* thisThread;
StateInfo* st;
int chess960;
-
- // Static variables
- static Score pieceSquareTable[16][64]; // [piece][square]
- static Key zobrist[2][8][64]; // [color][pieceType][square]/[piece count]
- static Key zobEp[8]; // [file]
- static Key zobCastle[16]; // [castleRight]
- static Key zobSideToMove;
- static Key zobExclusion;
};
inline int64_t Position::nodes_searched() const {
}
inline Key Position::exclusion_key() const {
- return st->key ^ zobExclusion;
+ return st->key ^ Zobrist::exclusion;
}
inline Key Position::pawn_key() const {