]> git.sesse.net Git - stockfish/blobdiff - src/position.h
Change Position::pst() signature
[stockfish] / src / position.h
index d822260dd768fb6eca1776435d80fb39cb7ad318..b30b1ffe4be16870be978dac20900351c3eace1b 100644 (file)
@@ -47,7 +47,7 @@ struct CheckInfo {
 
 /// Castle rights, encoded as bit fields
 
-enum CastleRights {
+enum CastleRight {
   CASTLES_NONE = 0,
   WHITE_OO     = 1,
   BLACK_OO     = 2,
@@ -154,11 +154,9 @@ public:
   Square king_square(Color c) const;
 
   // Castling rights
-  bool can_castle_kingside(Color c) const;
-  bool can_castle_queenside(Color c) const;
+  bool can_castle(CastleRight f) const;
   bool can_castle(Color c) const;
-  Square initial_kr_square(Color c) const;
-  Square initial_qr_square(Color c) const;
+  Square castle_rook_square(CastleRight f) const;
 
   // Bitboards for pinned pieces and discovered check candidates
   Bitboard discovered_check_candidates(Color c) const;
@@ -251,8 +249,7 @@ private:
   void clear();
   void detach();
   void put_piece(Piece p, Square s);
-  void set_castle_kingside(Color c);
-  void set_castle_queenside(Color c);
+  void set_castle(int f, Square ksq, Square rsq);
   void set_castling_rights(char token);
   bool move_is_pl_slow(const Move m) const;
 
@@ -271,7 +268,7 @@ private:
   Key compute_material_key() const;
 
   // Computing incremental evaluation scores and material counts
-  static Score pst(Color c, PieceType pt, Square s);
+  static Score pst(Piece p, Square s);
   Score compute_value() const;
   Value compute_non_pawn_material(Color c) const;
 
@@ -292,8 +289,8 @@ private:
   Color sideToMove;
   Key history[MaxGameLength];
   int castleRightsMask[64];
+  Square castleRookSquare[16]; // [CastleRights]
   StateInfo startState;
-  File initialKFile, initialKRFile, initialQRFile;
   bool chess960;
   int fullMoves;
   int threadID;
@@ -381,32 +378,16 @@ inline Square Position::king_square(Color c) const {
   return pieceList[c][KING][0];
 }
 
-inline bool Position::can_castle_kingside(Color c) const {
-  return st->castleRights & (WHITE_OO << c);
-}
-
-inline bool Position::can_castle_queenside(Color c) const {
-  return st->castleRights & (WHITE_OOO << c);
+inline bool Position::can_castle(CastleRight f) const {
+  return st->castleRights & f;
 }
 
 inline bool Position::can_castle(Color c) const {
   return st->castleRights & ((WHITE_OO | WHITE_OOO) << c);
 }
 
-inline void Position::set_castle_kingside(Color c) {
-  st->castleRights |= (WHITE_OO << c);
-}
-
-inline void Position::set_castle_queenside(Color c) {
-  st->castleRights |= (WHITE_OOO << c);
-}
-
-inline Square Position::initial_kr_square(Color c) const {
-  return relative_square(c, make_square(initialKRFile, RANK_1));
-}
-
-inline Square Position::initial_qr_square(Color c) const {
-  return relative_square(c, make_square(initialQRFile, RANK_1));
+inline Square Position::castle_rook_square(CastleRight f) const {
+  return castleRookSquare[f];
 }
 
 template<>
@@ -466,8 +447,8 @@ inline Key Position::get_material_key() const {
   return st->materialKey;
 }
 
-inline Score Position::pst(Color c, PieceType pt, Square s) {
-  return PieceSquareTable[make_piece(c, pt)][s];
+inline Score Position::pst(Piece p, Square s) {
+  return PieceSquareTable[p][s];
 }
 
 inline Score Position::pst_delta(Piece piece, Square from, Square to) {