CACHE_LINE_ALIGNMENT
-Score pieceSquareTable[PIECE_NB][SQUARE_NB];
+Score pieceSquareTable[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
Value PieceValue[PHASE_NB][PIECE_NB] = {
{ VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg },
{ VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg } };
side = rk.rand<Key>();
exclusion = rk.rand<Key>();
- for (Piece pc = W_PAWN; pc <= W_KING; pc++)
+ for (PieceType pt = PAWN; pt <= KING; pt++)
{
- PieceValue[MG][~pc] = PieceValue[MG][pc];
- PieceValue[EG][~pc] = PieceValue[EG][pc];
+ PieceValue[MG][make_piece(BLACK, pt)] = PieceValue[MG][pt];
+ PieceValue[EG][make_piece(BLACK, pt)] = PieceValue[EG][pt];
- Score v = make_score(PieceValue[MG][pc], PieceValue[EG][pc]);
+ Score v = make_score(PieceValue[MG][pt], PieceValue[EG][pt]);
for (Square s = SQ_A1; s <= SQ_H8; s++)
{
- pieceSquareTable[ pc][ s] = (v + PSQT[pc][s]);
- pieceSquareTable[~pc][~s] = -(v + PSQT[pc][s]);
+ pieceSquareTable[WHITE][pt][ s] = (v + PSQT[pt][s]);
+ pieceSquareTable[BLACK][pt][~s] = -(v + PSQT[pt][s]);
}
}
}
Color them = ~us;
Square from = from_sq(m);
Square to = to_sq(m);
- Piece piece = piece_on(from);
- PieceType pt = type_of(piece);
+ Piece pc = piece_on(from);
+ PieceType pt = type_of(pc);
PieceType capture = type_of(m) == ENPASSANT ? PAWN : type_of(piece_on(to));
- assert(color_of(piece) == us);
+ assert(color_of(pc) == us);
assert(piece_on(to) == NO_PIECE || color_of(piece_on(to)) == them || type_of(m) == CASTLE);
assert(capture != KING);
if (type_of(m) == CASTLE)
{
- assert(piece == make_piece(us, KING));
+ assert(pc == make_piece(us, KING));
bool kingSide = to > from;
Square rfrom = to; // Castle is encoded as "king captures friendly rook"
do_castle(from, to, rfrom, rto);
+ st->psqScore += pieceSquareTable[us][ROOK][rto] - pieceSquareTable[us][ROOK][rfrom];
k ^= Zobrist::psq[us][ROOK][rfrom] ^ Zobrist::psq[us][ROOK][rto];
- st->psqScore += pieceSquareTable[make_piece(us, ROOK)][rto]
- - pieceSquareTable[make_piece(us, ROOK)][rfrom];
}
if (capture)
prefetch((char*)thisThread->materialTable[st->materialKey]);
// Update incremental scores
- st->psqScore -= pieceSquareTable[make_piece(them, capture)][capsq];
+ st->psqScore -= pieceSquareTable[them][capture][capsq];
// Reset rule 50 counter
st->rule50 = 0;
byColorBB[us] ^= from_to_bb;
board[from] = NO_PIECE;
- board[to] = piece;
+ board[to] = pc;
// Update piece lists, index[from] is not updated and becomes stale. This
// works as long as index[] is accessed just by known occupied squares.
^ Zobrist::psq[us][PAWN][pieceCount[us][PAWN]];
// Update incremental score
- st->psqScore += pieceSquareTable[make_piece(us, promotion)][to]
- - pieceSquareTable[make_piece(us, PAWN)][to];
+ st->psqScore += pieceSquareTable[us][promotion][to] - pieceSquareTable[us][PAWN][to];
// Update material
st->npMaterial[us] += PieceValue[MG][promotion];
}
// Update incremental scores
- st->psqScore += pieceSquareTable[piece][to] - pieceSquareTable[piece][from];
+ st->psqScore += pieceSquareTable[us][pt][to] - pieceSquareTable[us][pt][from];
// Set capture piece
st->capturedType = capture;
for (Bitboard b = pieces(); b; )
{
Square s = pop_lsb(&b);
- score += pieceSquareTable[piece_on(s)][s];
+ Piece pc = piece_on(s);
+ score += pieceSquareTable[color_of(pc)][type_of(pc)][s];
}
return score;