mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 01:27:16 +08:00
Introduce operator~(Piece c)
Small syntactic sugar to reverse piece color. No functional change.
This commit is contained in:
@@ -85,17 +85,17 @@ void init() {
|
|||||||
side = rk.rand<Key>();
|
side = rk.rand<Key>();
|
||||||
exclusion = rk.rand<Key>();
|
exclusion = rk.rand<Key>();
|
||||||
|
|
||||||
for (PieceType pt = PAWN; pt <= KING; pt++)
|
for (Piece pc = W_PAWN; pc <= W_KING; pc++)
|
||||||
{
|
{
|
||||||
PieceValue[MG][make_piece(BLACK, pt)] = PieceValue[MG][pt];
|
PieceValue[MG][~pc] = PieceValue[MG][pc];
|
||||||
PieceValue[EG][make_piece(BLACK, pt)] = PieceValue[EG][pt];
|
PieceValue[EG][~pc] = PieceValue[EG][pc];
|
||||||
|
|
||||||
Score v = make_score(PieceValue[MG][pt], PieceValue[EG][pt]);
|
Score v = make_score(PieceValue[MG][pc], PieceValue[EG][pc]);
|
||||||
|
|
||||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||||
{
|
{
|
||||||
pieceSquareTable[make_piece(WHITE, pt)][ s] = (v + PSQT[pt][s]);
|
pieceSquareTable[ pc][ s] = (v + PSQT[pc][s]);
|
||||||
pieceSquareTable[make_piece(BLACK, pt)][~s] = -(v + PSQT[pt][s]);
|
pieceSquareTable[~pc][~s] = -(v + PSQT[pc][s]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#define S(mg, eg) make_score(mg, eg)
|
#define S(mg, eg) make_score(mg, eg)
|
||||||
|
|
||||||
|
|
||||||
/// PSQT[PieceType][Square] contains Piece-Square scores. For each piece type on
|
/// PSQT[Piece][Square] contains Piece-Square scores. For each piece type on
|
||||||
/// a given square a (midgame, endgame) score pair is assigned. PSQT is defined
|
/// a given square a (midgame, endgame) score pair is assigned. PSQT is defined
|
||||||
/// for white side, for black side the tables are symmetric.
|
/// for white side, for black side the tables are symmetric.
|
||||||
|
|
||||||
|
|||||||
@@ -359,6 +359,10 @@ inline Square operator~(Square s) {
|
|||||||
return Square(s ^ 56); // Vertical flip SQ_A1 -> SQ_A8
|
return Square(s ^ 56); // Vertical flip SQ_A1 -> SQ_A8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Piece operator~(Piece c) {
|
||||||
|
return Piece(c ^ 8);
|
||||||
|
}
|
||||||
|
|
||||||
inline Square operator|(File f, Rank r) {
|
inline Square operator|(File f, Rank r) {
|
||||||
return Square((r << 3) | f);
|
return Square((r << 3) | f);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user