X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpiece.h;h=341e877dab938863708cc6216676d0766e933fef;hp=b71f849d8e7b1639532112edf3d967cae940e8cc;hb=95212222c7444538b84326208e433ac12f15e9fb;hpb=5b2ac7590ccfe529698347981e45fdfa8a0a0780 diff --git a/src/piece.h b/src/piece.h index b71f849d..341e877d 100644 --- a/src/piece.h +++ b/src/piece.h @@ -20,7 +20,6 @@ #if !defined(PIECE_H_INCLUDED) #define PIECE_H_INCLUDED -#include "color.h" #include "value.h" enum PieceType { @@ -33,8 +32,13 @@ enum Piece { BP = 9, BN = 10, BB = 11, BR = 12, BQ = 13, BK = 14, PIECE_NONE = 16 }; +enum Color { + WHITE, BLACK, COLOR_NONE +}; + ENABLE_OPERATORS_ON(PieceType) ENABLE_OPERATORS_ON(Piece) +ENABLE_OPERATORS_ON(Color) /// Important: If the material values are changed, one must also /// adjust the piece square tables, and the method game_phase() in the @@ -53,6 +57,10 @@ const Value RookValueEndgame = Value(0x4FE); const Value QueenValueMidgame = Value(0x9D9); const Value QueenValueEndgame = Value(0x9FE); +inline Piece make_piece(Color c, PieceType pt) { + return Piece((int(c) << 3) | int(pt)); +} + inline PieceType type_of_piece(Piece p) { return PieceType(int(p) & 7); } @@ -61,8 +69,12 @@ inline Color color_of_piece(Piece p) { return Color(int(p) >> 3); } -inline Piece piece_of_color_and_type(Color c, PieceType pt) { - return Piece((int(c) << 3) | int(pt)); +inline Color opposite_color(Color c) { + return Color(int(c) ^ 1); +} + +inline bool color_is_ok(Color c) { + return c == WHITE || c == BLACK; } inline bool piece_type_is_ok(PieceType pt) {