-/// Position::init() is a static member function which initializes at startup
-/// the various arrays used to compute hash keys and the piece square tables.
-/// The latter is a two-step operation: First, the white halves of the tables
-/// are copied from PSQT[] tables. Second, the black halves of the tables are
-/// initialized by flipping and changing the sign of the white scores.
-
-void Position::init() {
-
- RKISS rk;
-
- for (Color c = WHITE; c <= BLACK; c++)
- for (PieceType pt = PAWN; pt <= KING; pt++)
- for (Square s = SQ_A1; s <= SQ_H8; s++)
- zobrist[c][pt][s] = rk.rand<Key>();
-
- for (File f = FILE_A; f <= FILE_H; f++)
- zobEp[f] = rk.rand<Key>();
-
- for (int cr = CASTLES_NONE; cr <= ALL_CASTLES; cr++)
- {
- Bitboard b = cr;
- while (b)
- {
- Key k = zobCastle[1 << pop_1st_bit(&b)];
- zobCastle[cr] ^= k ? k : rk.rand<Key>();
- }
- }
-
- zobSideToMove = rk.rand<Key>();
- zobExclusion = rk.rand<Key>();
-
- for (Piece p = W_PAWN; p <= W_KING; p++)
- {
- Score ps = make_score(PieceValueMidgame[p], PieceValueEndgame[p]);
-
- for (Square s = SQ_A1; s <= SQ_H8; s++)
- {
- pieceSquareTable[p][s] = ps + PSQT[p][s];
- pieceSquareTable[p+8][~s] = -pieceSquareTable[p][s];
- }
- }
-}
-
-
-/// Position::flip_me() flips position with the white and black sides reversed. This