mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Use operator~ to flip colors and squares
More natural and nicer. Idea from Critter. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
16
src/types.h
16
src/types.h
@@ -334,6 +334,14 @@ extern const Value PieceValueMidgame[17];
|
||||
extern const Value PieceValueEndgame[17];
|
||||
extern int SquareDistance[64][64];
|
||||
|
||||
inline Color operator~(Color c) {
|
||||
return Color(c ^ 1);
|
||||
}
|
||||
|
||||
inline Square operator~(Square s) {
|
||||
return Square(s ^ 56);
|
||||
}
|
||||
|
||||
inline Value mate_in(int ply) {
|
||||
return VALUE_MATE - ply;
|
||||
}
|
||||
@@ -354,10 +362,6 @@ inline Color color_of(Piece p) {
|
||||
return Color(p >> 3);
|
||||
}
|
||||
|
||||
inline Color flip(Color c) {
|
||||
return Color(c ^ 1);
|
||||
}
|
||||
|
||||
inline Square make_square(File f, Rank r) {
|
||||
return Square((r << 3) | f);
|
||||
}
|
||||
@@ -374,10 +378,6 @@ inline Rank rank_of(Square s) {
|
||||
return Rank(s >> 3);
|
||||
}
|
||||
|
||||
inline Square flip(Square s) {
|
||||
return Square(s ^ 56);
|
||||
}
|
||||
|
||||
inline Square mirror(Square s) {
|
||||
return Square(s ^ 7);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user