mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 09:39:36 +00:00
Introduce operator~(Piece c)
Small syntactic sugar to reverse piece color. No functional change.
This commit is contained in:
parent
7e95495b35
commit
db4cd89cb8
3 changed files with 11 additions and 7 deletions
|
@ -85,17 +85,17 @@ void init() {
|
|||
side = 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[EG][make_piece(BLACK, pt)] = PieceValue[EG][pt];
|
||||
PieceValue[MG][~pc] = PieceValue[MG][pc];
|
||||
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++)
|
||||
{
|
||||
pieceSquareTable[make_piece(WHITE, pt)][ s] = (v + PSQT[pt][s]);
|
||||
pieceSquareTable[make_piece(BLACK, pt)][~s] = -(v + PSQT[pt][s]);
|
||||
pieceSquareTable[ pc][ s] = (v + PSQT[pc][s]);
|
||||
pieceSquareTable[~pc][~s] = -(v + PSQT[pc][s]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#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
|
||||
/// 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
|
||||
}
|
||||
|
||||
inline Piece operator~(Piece c) {
|
||||
return Piece(c ^ 8);
|
||||
}
|
||||
|
||||
inline Square operator|(File f, Rank r) {
|
||||
return Square((r << 3) | f);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue