]> git.sesse.net Git - stockfish/commitdiff
Rename CASTLE to CASTLING
authorMarco Costalba <mcostalba@gmail.com>
Sun, 1 Dec 2013 09:25:10 +0000 (10:25 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 1 Dec 2013 10:16:47 +0000 (11:16 +0100)
It is call 'castling move', not 'castle move'

Noticed while reading DiscoCheck sources.

No functional change.

src/book.cpp
src/evaluate.cpp
src/movegen.cpp
src/notation.cpp
src/pawns.cpp
src/pawns.h
src/position.cpp
src/position.h
src/search.cpp
src/types.h

index 8d021ab262118d3a529b1eec2e52aea9690572b4..da45b32484c47abf8142ef5c537a8a417a28fcb0 100644 (file)
@@ -49,7 +49,7 @@ namespace {
     Key PolyGlotRandoms[781];
     struct {
       Key psq[12][64];  // [piece][square]
     Key PolyGlotRandoms[781];
     struct {
       Key psq[12][64];  // [piece][square]
-      Key castle[4];    // [castle right]
+      Key castling[4];  // [castling flag]
       Key enpassant[8]; // [file]
       Key turn;
     } Zobrist;
       Key enpassant[8]; // [file]
       Key turn;
     } Zobrist;
@@ -332,10 +332,10 @@ namespace {
         key ^= PG.Zobrist.psq[2 * (type_of(p) - 1) + (color_of(p) == WHITE)][s];
     }
 
         key ^= PG.Zobrist.psq[2 * (type_of(p) - 1) + (color_of(p) == WHITE)][s];
     }
 
-    b = pos.can_castle(ALL_CASTLES);
+    b = pos.can_castle(ANY_CASTLING);
 
     while (b)
 
     while (b)
-        key ^= PG.Zobrist.castle[pop_lsb(&b)];
+        key ^= PG.Zobrist.castling[pop_lsb(&b)];
 
     if (pos.ep_square() != SQ_NONE)
         key ^= PG.Zobrist.enpassant[file_of(pos.ep_square())];
 
     if (pos.ep_square() != SQ_NONE)
         key ^= PG.Zobrist.enpassant[file_of(pos.ep_square())];
index dd719554e18971081f4bd3648d7cbafdec268bc8..a9c4c4e787fc69f0d1530f5a1a8b3cca15dd8e42 100644 (file)
@@ -569,7 +569,7 @@ Value do_evaluate(const Position& pos) {
             Square ksq = pos.king_square(Us);
 
             // Penalize rooks which are trapped inside a king. Penalize more if
             Square ksq = pos.king_square(Us);
 
             // Penalize rooks which are trapped inside a king. Penalize more if
-            // king has lost right to castle.
+            // king has lost castling availability.
             if (   ((file_of(ksq) < FILE_E) == (file_of(s) < file_of(ksq)))
                 && (rank_of(ksq) == rank_of(s) || relative_rank(Us, ksq) == RANK_1)
                 && !ei.pi->semiopen_on_side(Us, file_of(ksq), file_of(ksq) < FILE_E))
             if (   ((file_of(ksq) < FILE_E) == (file_of(s) < file_of(ksq)))
                 && (rank_of(ksq) == rank_of(s) || relative_rank(Us, ksq) == RANK_1)
                 && !ei.pi->semiopen_on_side(Us, file_of(ksq), file_of(ksq) < FILE_E))
index a3623a69e5e4369bfcfcae701e04cdce4c2d82d0..ee138b912687febc3a8030d53a8e0831b251b50d 100644 (file)
 namespace {
 
   template<CastlingSide Side, bool Checks, bool Chess960>
 namespace {
 
   template<CastlingSide Side, bool Checks, bool Chess960>
-  ExtMove* generate_castle(const Position& pos, ExtMove* mlist, Color us) {
+  ExtMove* generate_castling(const Position& pos, ExtMove* mlist, Color us) {
 
 
-    if (pos.castle_impeded(us, Side) || !pos.can_castle(make_castle_right(us, Side)))
+    if (pos.castling_impeded(us, Side) || !pos.can_castle(make_castling_flag(us, Side)))
         return mlist;
 
     // After castling, the rook and king final positions are the same in Chess960
     // as they would be in standard chess.
     Square kfrom = pos.king_square(us);
         return mlist;
 
     // After castling, the rook and king final positions are the same in Chess960
     // as they would be in standard chess.
     Square kfrom = pos.king_square(us);
-    Square rfrom = pos.castle_rook_square(us, Side);
+    Square rfrom = pos.castling_rook_square(us, Side);
     Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
     Bitboard enemies = pos.pieces(~us);
 
     Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
     Bitboard enemies = pos.pieces(~us);
 
@@ -59,7 +59,7 @@ namespace {
     if (Chess960 && (attacks_bb<ROOK>(kto, pos.pieces() ^ rfrom) & pos.pieces(~us, ROOK, QUEEN)))
         return mlist;
 
     if (Chess960 && (attacks_bb<ROOK>(kto, pos.pieces() ^ rfrom) & pos.pieces(~us, ROOK, QUEEN)))
         return mlist;
 
-    (mlist++)->move = make<CASTLE>(kfrom, rfrom);
+    (mlist++)->move = make<CASTLING>(kfrom, rfrom);
 
     if (Checks && !pos.gives_check((mlist - 1)->move, CheckInfo(pos)))
         --mlist;
 
     if (Checks && !pos.gives_check((mlist - 1)->move, CheckInfo(pos)))
         --mlist;
@@ -260,13 +260,13 @@ namespace {
     {
         if (pos.is_chess960())
         {
     {
         if (pos.is_chess960())
         {
-            mlist = generate_castle< KING_SIDE, Checks, true>(pos, mlist, Us);
-            mlist = generate_castle<QUEEN_SIDE, Checks, true>(pos, mlist, Us);
+            mlist = generate_castling< KING_SIDE, Checks, true>(pos, mlist, Us);
+            mlist = generate_castling<QUEEN_SIDE, Checks, true>(pos, mlist, Us);
         }
         else
         {
         }
         else
         {
-            mlist = generate_castle< KING_SIDE, Checks, false>(pos, mlist, Us);
-            mlist = generate_castle<QUEEN_SIDE, Checks, false>(pos, mlist, Us);
+            mlist = generate_castling< KING_SIDE, Checks, false>(pos, mlist, Us);
+            mlist = generate_castling<QUEEN_SIDE, Checks, false>(pos, mlist, Us);
         }
     }
 
         }
     }
 
index d017c0790cc801b42842b949eb9c2c85d210e788..a1b95bc087650858f10e2de33cff3ede5f69218b 100644 (file)
@@ -56,7 +56,7 @@ string score_to_uci(Value v, Value alpha, Value beta) {
 /// move_to_uci() converts a move to a string in coordinate notation
 /// (g1f3, a7a8q, etc.). The only special case is castling moves, where we print
 /// in the e1g1 notation in normal chess mode, and in e1h1 notation in chess960
 /// move_to_uci() converts a move to a string in coordinate notation
 /// (g1f3, a7a8q, etc.). The only special case is castling moves, where we print
 /// in the e1g1 notation in normal chess mode, and in e1h1 notation in chess960
-/// mode. Internally castle moves are always coded as "king captures rook".
+/// mode. Internally castling moves are always encoded as "king captures rook".
 
 const string move_to_uci(Move m, bool chess960) {
 
 
 const string move_to_uci(Move m, bool chess960) {
 
@@ -69,7 +69,7 @@ const string move_to_uci(Move m, bool chess960) {
   if (m == MOVE_NULL)
       return "0000";
 
   if (m == MOVE_NULL)
       return "0000";
 
-  if (type_of(m) == CASTLE && !chess960)
+  if (type_of(m) == CASTLING && !chess960)
       to = (to > from ? FILE_G : FILE_C) | rank_of(from);
 
   string move = square_to_string(from) + square_to_string(to);
       to = (to > from ? FILE_G : FILE_C) | rank_of(from);
 
   string move = square_to_string(from) + square_to_string(to);
@@ -118,7 +118,7 @@ const string move_to_san(Position& pos, Move m) {
   Piece pc = pos.piece_on(from);
   PieceType pt = type_of(pc);
 
   Piece pc = pos.piece_on(from);
   PieceType pt = type_of(pc);
 
-  if (type_of(m) == CASTLE)
+  if (type_of(m) == CASTLING)
       san = to > from ? "O-O" : "O-O-O";
   else
   {
       san = to > from ? "O-O" : "O-O-O";
   else
   {
index d2a53ef9679a1d69ee1655530b9af05cd39b382b..0bd99f9b0e6d9058f9f9e49b6efd21cced6416a6 100644 (file)
@@ -259,7 +259,7 @@ template<Color Us>
 Score Entry::update_safety(const Position& pos, Square ksq) {
 
   kingSquares[Us] = ksq;
 Score Entry::update_safety(const Position& pos, Square ksq) {
 
   kingSquares[Us] = ksq;
-  castleRights[Us] = pos.can_castle(Us);
+  castlingFlags[Us] = pos.can_castle(Us);
   minKPdistance[Us] = 0;
 
   Bitboard pawns = pos.pieces(Us, PAWN);
   minKPdistance[Us] = 0;
 
   Bitboard pawns = pos.pieces(Us, PAWN);
@@ -271,11 +271,11 @@ Score Entry::update_safety(const Position& pos, Square ksq) {
 
   Value bonus = shelter_storm<Us>(pos, ksq);
 
 
   Value bonus = shelter_storm<Us>(pos, ksq);
 
-  // If we can castle use the bonus after the castle if it is bigger
-  if (pos.can_castle(make_castle_right(Us, KING_SIDE)))
+  // If we can castle use the bonus after the castling if it is bigger
+  if (pos.can_castle(make_castling_flag(Us, KING_SIDE)))
       bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_G1)));
 
       bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_G1)));
 
-  if (pos.can_castle(make_castle_right(Us, QUEEN_SIDE)))
+  if (pos.can_castle(make_castling_flag(Us, QUEEN_SIDE)))
       bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_C1)));
 
   return kingSafety[Us] = make_score(bonus, -16 * minKPdistance[Us]);
       bonus = std::max(bonus, shelter_storm<Us>(pos, relative_square(Us, SQ_C1)));
 
   return kingSafety[Us] = make_score(bonus, -16 * minKPdistance[Us]);
index f6be84e774ed122d86cd8d8be9a351c64bc1340b..0099ec209d736184cc43186f22632783a4f289c9 100644 (file)
@@ -48,7 +48,7 @@ struct Entry {
   template<Color Us>
   Score king_safety(const Position& pos, Square ksq)  {
 
   template<Color Us>
   Score king_safety(const Position& pos, Square ksq)  {
 
-    return kingSquares[Us] == ksq && castleRights[Us] == pos.can_castle(Us)
+    return kingSquares[Us] == ksq && castlingFlags[Us] == pos.can_castle(Us)
          ? kingSafety[Us] : update_safety<Us>(pos, ksq);
   }
 
          ? kingSafety[Us] : update_safety<Us>(pos, ksq);
   }
 
@@ -64,7 +64,7 @@ struct Entry {
   Bitboard pawnAttacks[COLOR_NB];
   Square kingSquares[COLOR_NB];
   int minKPdistance[COLOR_NB];
   Bitboard pawnAttacks[COLOR_NB];
   Square kingSquares[COLOR_NB];
   int minKPdistance[COLOR_NB];
-  int castleRights[COLOR_NB];
+  int castlingFlags[COLOR_NB];
   Score value;
   int semiopenFiles[COLOR_NB];
   Score kingSafety[COLOR_NB];
   Score value;
   int semiopenFiles[COLOR_NB];
   Score kingSafety[COLOR_NB];
index 2f3c62f552ac8fec90ef1e1bb3fa1d8f7600702e..f6b8d0ce0633675040893eb2f4a29aebfddfccb9 100644 (file)
@@ -47,7 +47,7 @@ namespace Zobrist {
 
   Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
   Key enpassant[FILE_NB];
 
   Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
   Key enpassant[FILE_NB];
-  Key castle[CASTLE_RIGHT_NB];
+  Key castling[CASTLING_FLAG_NB];
   Key side;
   Key exclusion;
 }
   Key side;
   Key exclusion;
 }
@@ -125,13 +125,13 @@ void Position::init() {
   for (File f = FILE_A; f <= FILE_H; ++f)
       Zobrist::enpassant[f] = rk.rand<Key>();
 
   for (File f = FILE_A; f <= FILE_H; ++f)
       Zobrist::enpassant[f] = rk.rand<Key>();
 
-  for (int cr = CASTLES_NONE; cr <= ALL_CASTLES; ++cr)
+  for (int cf = NO_CASTLING; cf <= ANY_CASTLING; ++cf)
   {
   {
-      Bitboard b = cr;
+      Bitboard b = cf;
       while (b)
       {
       while (b)
       {
-          Key k = Zobrist::castle[1ULL << pop_lsb(&b)];
-          Zobrist::castle[cr] ^= k ? k : rk.rand<Key>();
+          Key k = Zobrist::castling[1ULL << pop_lsb(&b)];
+          Zobrist::castling[cf] ^= k ? k : rk.rand<Key>();
       }
   }
 
       }
   }
 
@@ -263,7 +263,7 @@ void Position::set(const string& fenStr, bool isChess960, Thread* th) {
       else
           continue;
 
       else
           continue;
 
-      set_castle_right(c, rsq);
+      set_castling_flag(c, rsq);
   }
 
   // 4. En passant square. Ignore if no pawn capture is possible
   }
 
   // 4. En passant square. Ignore if no pawn capture is possible
@@ -297,30 +297,30 @@ void Position::set(const string& fenStr, bool isChess960, Thread* th) {
 }
 
 
 }
 
 
-/// Position::set_castle_right() is an helper function used to set castling
-/// rights given the corresponding color and the rook starting square.
+/// Position::set_castling_flag() is an helper function used to set castling
+/// flags given the corresponding color and the rook starting square.
 
 
-void Position::set_castle_right(Color c, Square rfrom) {
+void Position::set_castling_flag(Color c, Square rfrom) {
 
   Square kfrom = king_square(c);
   CastlingSide cs = kfrom < rfrom ? KING_SIDE : QUEEN_SIDE;
 
   Square kfrom = king_square(c);
   CastlingSide cs = kfrom < rfrom ? KING_SIDE : QUEEN_SIDE;
-  CastleRight cr = make_castle_right(c, cs);
+  CastlingFlag cf = make_castling_flag(c, cs);
 
 
-  st->castleRights |= cr;
-  castleRightsMask[kfrom] |= cr;
-  castleRightsMask[rfrom] |= cr;
-  castleRookSquare[c][cs] = rfrom;
+  st->castlingFlags |= cf;
+  castlingFlagsMask[kfrom] |= cf;
+  castlingFlagsMask[rfrom] |= cf;
+  castlingRookSquare[c][cs] = rfrom;
 
   Square kto = relative_square(c, cs == KING_SIDE ? SQ_G1 : SQ_C1);
   Square rto = relative_square(c, cs == KING_SIDE ? SQ_F1 : SQ_D1);
 
   for (Square s = std::min(rfrom, rto); s <= std::max(rfrom, rto); ++s)
       if (s != kfrom && s != rfrom)
 
   Square kto = relative_square(c, cs == KING_SIDE ? SQ_G1 : SQ_C1);
   Square rto = relative_square(c, cs == KING_SIDE ? SQ_F1 : SQ_D1);
 
   for (Square s = std::min(rfrom, rto); s <= std::max(rfrom, rto); ++s)
       if (s != kfrom && s != rfrom)
-          castlePath[c][cs] |= s;
+          castlingPath[c][cs] |= s;
 
   for (Square s = std::min(kfrom, kto); s <= std::max(kfrom, kto); ++s)
       if (s != kfrom && s != rfrom)
 
   for (Square s = std::min(kfrom, kto); s <= std::max(kfrom, kto); ++s)
       if (s != kfrom && s != rfrom)
-          castlePath[c][cs] |= s;
+          castlingPath[c][cs] |= s;
 }
 
 
 }
 
 
@@ -357,18 +357,18 @@ const string Position::fen() const {
   ss << (sideToMove == WHITE ? " w " : " b ");
 
   if (can_castle(WHITE_OO))
   ss << (sideToMove == WHITE ? " w " : " b ");
 
   if (can_castle(WHITE_OO))
-      ss << (chess960 ? file_to_char(file_of(castle_rook_square(WHITE,  KING_SIDE)), false) : 'K');
+      ss << (chess960 ? file_to_char(file_of(castling_rook_square(WHITE,  KING_SIDE)), false) : 'K');
 
   if (can_castle(WHITE_OOO))
 
   if (can_castle(WHITE_OOO))
-      ss << (chess960 ? file_to_char(file_of(castle_rook_square(WHITE, QUEEN_SIDE)), false) : 'Q');
+      ss << (chess960 ? file_to_char(file_of(castling_rook_square(WHITE, QUEEN_SIDE)), false) : 'Q');
 
   if (can_castle(BLACK_OO))
 
   if (can_castle(BLACK_OO))
-      ss << (chess960 ? file_to_char(file_of(castle_rook_square(BLACK,  KING_SIDE)),  true) : 'k');
+      ss << (chess960 ? file_to_char(file_of(castling_rook_square(BLACK,  KING_SIDE)),  true) : 'k');
 
   if (can_castle(BLACK_OOO))
 
   if (can_castle(BLACK_OOO))
-      ss << (chess960 ? file_to_char(file_of(castle_rook_square(BLACK, QUEEN_SIDE)),  true) : 'q');
+      ss << (chess960 ? file_to_char(file_of(castling_rook_square(BLACK, QUEEN_SIDE)),  true) : 'q');
 
 
-  if (st->castleRights == CASTLES_NONE)
+  if (st->castlingFlags == NO_CASTLING)
       ss << '-';
 
   ss << (ep_square() == SQ_NONE ? " - " : " " + square_to_string(ep_square()) + " ")
       ss << '-';
 
   ss << (ep_square() == SQ_NONE ? " - " : " " + square_to_string(ep_square()) + " ")
@@ -489,7 +489,7 @@ bool Position::legal(Move m, Bitboard pinned) const {
   // square is attacked by the opponent. Castling moves are checked
   // for legality during move generation.
   if (type_of(piece_on(from)) == KING)
   // square is attacked by the opponent. Castling moves are checked
   // for legality during move generation.
   if (type_of(piece_on(from)) == KING)
-      return type_of(m) == CASTLE || !(attackers_to(to_sq(m)) & pieces(~us));
+      return type_of(m) == CASTLING || !(attackers_to(to_sq(m)) & pieces(~us));
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.
@@ -663,10 +663,10 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
       return  (attacks_bb<  ROOK>(ksq, b) & pieces(us, QUEEN, ROOK))
             | (attacks_bb<BISHOP>(ksq, b) & pieces(us, QUEEN, BISHOP));
   }
       return  (attacks_bb<  ROOK>(ksq, b) & pieces(us, QUEEN, ROOK))
             | (attacks_bb<BISHOP>(ksq, b) & pieces(us, QUEEN, BISHOP));
   }
-  case CASTLE:
+  case CASTLING:
   {
       Square kfrom = from;
   {
       Square kfrom = from;
-      Square rfrom = to; // 'King captures the rook' notation
+      Square rfrom = to; // Castling is encoded as 'King captures the rook'
       Square kto = relative_square(us, rfrom > kfrom ? SQ_G1 : SQ_C1);
       Square rto = relative_square(us, rfrom > kfrom ? SQ_F1 : SQ_D1);
 
       Square kto = relative_square(us, rfrom > kfrom ? SQ_G1 : SQ_C1);
       Square rto = relative_square(us, rfrom > kfrom ? SQ_F1 : SQ_D1);
 
@@ -724,20 +724,20 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
   PieceType captured = type_of(m) == ENPASSANT ? PAWN : type_of(piece_on(to));
 
   assert(color_of(pc) == us);
   PieceType captured = type_of(m) == ENPASSANT ? PAWN : type_of(piece_on(to));
 
   assert(color_of(pc) == us);
-  assert(piece_on(to) == NO_PIECE || color_of(piece_on(to)) == them || type_of(m) == CASTLE);
+  assert(piece_on(to) == NO_PIECE || color_of(piece_on(to)) == them || type_of(m) == CASTLING);
   assert(captured != KING);
 
   assert(captured != KING);
 
-  if (type_of(m) == CASTLE)
+  if (type_of(m) == CASTLING)
   {
       assert(pc == make_piece(us, KING));
 
       bool kingSide = to > from;
   {
       assert(pc == make_piece(us, KING));
 
       bool kingSide = to > from;
-      Square rfrom = to; // Castle is encoded as "king captures friendly rook"
+      Square rfrom = to; // Castling is encoded as "king captures friendly rook"
       Square rto = relative_square(us, kingSide ? SQ_F1 : SQ_D1);
       to = relative_square(us, kingSide ? SQ_G1 : SQ_C1);
       captured = NO_PIECE_TYPE;
 
       Square rto = relative_square(us, kingSide ? SQ_F1 : SQ_D1);
       to = relative_square(us, kingSide ? SQ_G1 : SQ_C1);
       captured = NO_PIECE_TYPE;
 
-      do_castle(from, to, rfrom, rto);
+      do_castling(from, to, rfrom, rto);
 
       st->psq += psq[us][ROOK][rto] - psq[us][ROOK][rfrom];
       k ^= Zobrist::psq[us][ROOK][rfrom] ^ Zobrist::psq[us][ROOK][rto];
 
       st->psq += psq[us][ROOK][rto] - psq[us][ROOK][rfrom];
       k ^= Zobrist::psq[us][ROOK][rfrom] ^ Zobrist::psq[us][ROOK][rto];
@@ -794,19 +794,19 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
       st->epSquare = SQ_NONE;
   }
 
       st->epSquare = SQ_NONE;
   }
 
-  // Update castle rights if needed
-  if (st->castleRights && (castleRightsMask[from] | castleRightsMask[to]))
+  // Update castling flags if needed
+  if (st->castlingFlags && (castlingFlagsMask[from] | castlingFlagsMask[to]))
   {
   {
-      int cr = castleRightsMask[from] | castleRightsMask[to];
-      k ^= Zobrist::castle[st->castleRights & cr];
-      st->castleRights &= ~cr;
+      int cf = castlingFlagsMask[from] | castlingFlagsMask[to];
+      k ^= Zobrist::castling[st->castlingFlags & cf];
+      st->castlingFlags &= ~cf;
   }
 
   // Prefetch TT access as soon as we know the new hash key
   prefetch((char*)TT.first_entry(k));
 
   }
 
   // Prefetch TT access as soon as we know the new hash key
   prefetch((char*)TT.first_entry(k));
 
-  // Move the piece. The tricky Chess960 castle is handled earlier
-  if (type_of(m) != CASTLE)
+  // Move the piece. The tricky Chess960 castling is handled earlier
+  if (type_of(m) != CASTLING)
       move_piece(from, to, us, pt);
 
   // If the moving piece is a pawn do some special extra work
       move_piece(from, to, us, pt);
 
   // If the moving piece is a pawn do some special extra work
@@ -907,7 +907,7 @@ void Position::undo_move(Move m) {
   PieceType pt = type_of(piece_on(to));
   PieceType captured = st->capturedType;
 
   PieceType pt = type_of(piece_on(to));
   PieceType captured = st->capturedType;
 
-  assert(empty(from) || type_of(m) == CASTLE);
+  assert(empty(from) || type_of(m) == CASTLING);
   assert(captured != KING);
 
   if (type_of(m) == PROMOTION)
   assert(captured != KING);
 
   if (type_of(m) == PROMOTION)
@@ -923,15 +923,15 @@ void Position::undo_move(Move m) {
       pt = PAWN;
   }
 
       pt = PAWN;
   }
 
-  if (type_of(m) == CASTLE)
+  if (type_of(m) == CASTLING)
   {
       bool kingSide = to > from;
   {
       bool kingSide = to > from;
-      Square rfrom = to; // Castle is encoded as "king captures friendly rook"
+      Square rfrom = to; // Castling is encoded as "king captures friendly rook"
       Square rto = relative_square(us, kingSide ? SQ_F1 : SQ_D1);
       to = relative_square(us, kingSide ? SQ_G1 : SQ_C1);
       captured = NO_PIECE_TYPE;
       pt = KING;
       Square rto = relative_square(us, kingSide ? SQ_F1 : SQ_D1);
       to = relative_square(us, kingSide ? SQ_G1 : SQ_C1);
       captured = NO_PIECE_TYPE;
       pt = KING;
-      do_castle(to, from, rto, rfrom);
+      do_castling(to, from, rto, rfrom);
   }
   else
       move_piece(to, from, us, pt); // Put the piece back at the source square
   }
   else
       move_piece(to, from, us, pt); // Put the piece back at the source square
@@ -961,10 +961,10 @@ void Position::undo_move(Move m) {
 }
 
 
 }
 
 
-/// Position::do_castle() is a helper used to do/undo a castling move. This
+/// Position::do_castling() is a helper used to do/undo a castling move. This
 /// is a bit tricky, especially in Chess960.
 
 /// is a bit tricky, especially in Chess960.
 
-void Position::do_castle(Square kfrom, Square kto, Square rfrom, Square rto) {
+void Position::do_castling(Square kfrom, Square kto, Square rfrom, Square rto) {
 
   // Remove both pieces first since squares could overlap in Chess960
   remove_piece(kfrom, sideToMove, KING);
 
   // Remove both pieces first since squares could overlap in Chess960
   remove_piece(kfrom, sideToMove, KING);
@@ -1048,10 +1048,10 @@ int Position::see(Move m, int asymmThreshold) const {
   stm = color_of(piece_on(from));
   occupied = pieces() ^ from;
 
   stm = color_of(piece_on(from));
   occupied = pieces() ^ from;
 
-  // Castle moves are implemented as king capturing the rook so cannot be
+  // Castling moves are implemented as king capturing the rook so cannot be
   // handled correctly. Simply return 0 that is always the correct value
   // unless in the rare case the rook ends up under attack.
   // handled correctly. Simply return 0 that is always the correct value
   // unless in the rare case the rook ends up under attack.
-  if (type_of(m) == CASTLE)
+  if (type_of(m) == CASTLING)
       return 0;
 
   if (type_of(m) == ENPASSANT)
       return 0;
 
   if (type_of(m) == ENPASSANT)
@@ -1139,7 +1139,7 @@ void Position::clear() {
 
 Key Position::compute_key() const {
 
 
 Key Position::compute_key() const {
 
-  Key k = Zobrist::castle[st->castleRights];
+  Key k = Zobrist::castling[st->castlingFlags];
 
   for (Bitboard b = pieces(); b; )
   {
 
   for (Bitboard b = pieces(); b; )
   {
@@ -1326,7 +1326,7 @@ bool Position::pos_is_ok(int* failedStep) const {
   const bool debugNonPawnMaterial = all || false;
   const bool debugPieceCounts     = all || false;
   const bool debugPieceList       = all || false;
   const bool debugNonPawnMaterial = all || false;
   const bool debugPieceCounts     = all || false;
   const bool debugPieceList       = all || false;
-  const bool debugCastleSquares   = all || false;
+  const bool debugCastlingSquares = all || false;
 
   *step = 1;
 
 
   *step = 1;
 
@@ -1410,18 +1410,18 @@ bool Position::pos_is_ok(int* failedStep) const {
                       || index[pieceList[c][pt][i]] != i)
                       return false;
 
                       || index[pieceList[c][pt][i]] != i)
                       return false;
 
-  if ((*step)++, debugCastleSquares)
+  if ((*step)++, debugCastlingSquares)
       for (Color c = WHITE; c <= BLACK; ++c)
           for (CastlingSide s = KING_SIDE; s <= QUEEN_SIDE; s = CastlingSide(s + 1))
           {
       for (Color c = WHITE; c <= BLACK; ++c)
           for (CastlingSide s = KING_SIDE; s <= QUEEN_SIDE; s = CastlingSide(s + 1))
           {
-              CastleRight cr = make_castle_right(c, s);
+              CastlingFlag cf = make_castling_flag(c, s);
 
 
-              if (!can_castle(cr))
+              if (!can_castle(cf))
                   continue;
 
                   continue;
 
-              if (  (castleRightsMask[king_square(c)] & cr) != cr
-                  || piece_on(castleRookSquare[c][s]) != make_piece(c, ROOK)
-                  || castleRightsMask[castleRookSquare[c][s]] != cr)
+              if (  (castlingFlagsMask[king_square(c)] & cf) != cf
+                  || piece_on(castlingRookSquare[c][s]) != make_piece(c, ROOK)
+                  || castlingFlagsMask[castlingRookSquare[c][s]] != cf)
                   return false;
           }
 
                   return false;
           }
 
index cd297df737839e15967b37a280f7cc054c8a70c0..903b1b646e1a475dbdaebe7fdf86ac7a799bcd84 100644 (file)
@@ -51,7 +51,7 @@ struct CheckInfo {
 struct StateInfo {
   Key pawnKey, materialKey;
   Value npMaterial[COLOR_NB];
 struct StateInfo {
   Key pawnKey, materialKey;
   Value npMaterial[COLOR_NB];
-  int castleRights, rule50, pliesFromNull;
+  int castlingFlags, rule50, pliesFromNull;
   Score psq;
   Square epSquare;
 
   Score psq;
   Square epSquare;
 
@@ -100,10 +100,10 @@ public:
   template<PieceType Pt> const Square* list(Color c) const;
 
   // Castling
   template<PieceType Pt> const Square* list(Color c) const;
 
   // Castling
-  int can_castle(CastleRight f) const;
+  int can_castle(CastlingFlag f) const;
   int can_castle(Color c) const;
   int can_castle(Color c) const;
-  bool castle_impeded(Color c, CastlingSide s) const;
-  Square castle_rook_square(Color c, CastlingSide s) const;
+  bool castling_impeded(Color c, CastlingSide s) const;
+  Square castling_rook_square(Color c, CastlingSide s) const;
 
   // Checking
   Bitboard checkers() const;
 
   // Checking
   Bitboard checkers() const;
@@ -170,10 +170,10 @@ public:
 private:
   // Initialization helpers (used while setting up a position)
   void clear();
 private:
   // Initialization helpers (used while setting up a position)
   void clear();
-  void set_castle_right(Color c, Square rfrom);
+  void set_castling_flag(Color c, Square rfrom);
 
   // Helper functions
 
   // Helper functions
-  void do_castle(Square kfrom, Square kto, Square rfrom, Square rto);
+  void do_castling(Square kfrom, Square kto, Square rfrom, Square rto);
   Bitboard hidden_checkers(Square ksq, Color c, Color toMove) const;
   void put_piece(Square s, Color c, PieceType pt);
   void remove_piece(Square s, Color c, PieceType pt);
   Bitboard hidden_checkers(Square ksq, Color c, Color toMove) const;
   void put_piece(Square s, Color c, PieceType pt);
   void remove_piece(Square s, Color c, PieceType pt);
@@ -197,9 +197,9 @@ private:
   int index[SQUARE_NB];
 
   // Other info
   int index[SQUARE_NB];
 
   // Other info
-  int castleRightsMask[SQUARE_NB];
-  Square castleRookSquare[COLOR_NB][CASTLING_SIDE_NB];
-  Bitboard castlePath[COLOR_NB][CASTLING_SIDE_NB];
+  int castlingFlagsMask[SQUARE_NB];
+  Square castlingRookSquare[COLOR_NB][CASTLING_SIDE_NB];
+  Bitboard castlingPath[COLOR_NB][CASTLING_SIDE_NB];
   StateInfo startState;
   int64_t nodes;
   int gamePly;
   StateInfo startState;
   int64_t nodes;
   int gamePly;
@@ -273,20 +273,20 @@ inline Square Position::king_square(Color c) const {
   return pieceList[c][KING][0];
 }
 
   return pieceList[c][KING][0];
 }
 
-inline int Position::can_castle(CastleRight f) const {
-  return st->castleRights & f;
+inline int Position::can_castle(CastlingFlag f) const {
+  return st->castlingFlags & f;
 }
 
 inline int Position::can_castle(Color c) const {
 }
 
 inline int Position::can_castle(Color c) const {
-  return st->castleRights & ((WHITE_OO | WHITE_OOO) << (2 * c));
+  return st->castlingFlags & ((WHITE_OO | WHITE_OOO) << (2 * c));
 }
 
 }
 
-inline bool Position::castle_impeded(Color c, CastlingSide s) const {
-  return byTypeBB[ALL_PIECES] & castlePath[c][s];
+inline bool Position::castling_impeded(Color c, CastlingSide s) const {
+  return byTypeBB[ALL_PIECES] & castlingPath[c][s];
 }
 
 }
 
-inline Square Position::castle_rook_square(Color c, CastlingSide s) const {
-  return castleRookSquare[c][s];
+inline Square Position::castling_rook_square(Color c, CastlingSide s) const {
+  return castlingRookSquare[c][s];
 }
 
 template<PieceType Pt>
 }
 
 template<PieceType Pt>
@@ -380,14 +380,14 @@ inline bool Position::is_chess960() const {
 inline bool Position::capture_or_promotion(Move m) const {
 
   assert(is_ok(m));
 inline bool Position::capture_or_promotion(Move m) const {
 
   assert(is_ok(m));
-  return type_of(m) ? type_of(m) != CASTLE : !empty(to_sq(m));
+  return type_of(m) ? type_of(m) != CASTLING : !empty(to_sq(m));
 }
 
 inline bool Position::capture(Move m) const {
 
 }
 
 inline bool Position::capture(Move m) const {
 
-  // Note that castle is coded as "king captures the rook"
+  // Note that castling is encoded as "king captures the rook"
   assert(is_ok(m));
   assert(is_ok(m));
-  return (!empty(to_sq(m)) && type_of(m) != CASTLE) || type_of(m) == ENPASSANT;
+  return (!empty(to_sq(m)) && type_of(m) != CASTLING) || type_of(m) == ENPASSANT;
 }
 
 inline PieceType Position::captured_piece_type() const {
 }
 
 inline PieceType Position::captured_piece_type() const {
index e235c3fc615733c6e68ae879381c6b48ba7bba2e..a4e2309e2ea404031fe10689eee2ec07cf434b16 100644 (file)
@@ -807,7 +807,7 @@ moves_loop: // When in check and at SpNode search starts from here
       givesCheck = pos.gives_check(move, ci);
       dangerous =   givesCheck
                  || pos.passed_pawn_push(move)
       givesCheck = pos.gives_check(move, ci);
       dangerous =   givesCheck
                  || pos.passed_pawn_push(move)
-                 || type_of(move) == CASTLE;
+                 || type_of(move) == CASTLING;
 
       // Step 12. Extend checks
       if (givesCheck && pos.see_sign(move) >= 0)
 
       // Step 12. Extend checks
       if (givesCheck && pos.see_sign(move) >= 0)
@@ -1332,7 +1332,7 @@ moves_loop: // When in check and at SpNode search starts from here
     assert(is_ok(first));
     assert(is_ok(second));
     assert(color_of(pos.piece_on(from_sq(second))) == ~pos.side_to_move());
     assert(is_ok(first));
     assert(is_ok(second));
     assert(color_of(pos.piece_on(from_sq(second))) == ~pos.side_to_move());
-    assert(type_of(first) == CASTLE || color_of(pos.piece_on(to_sq(first))) == ~pos.side_to_move());
+    assert(type_of(first) == CASTLING || color_of(pos.piece_on(to_sq(first))) == ~pos.side_to_move());
 
     Square m1from = from_sq(first);
     Square m2from = from_sq(second);
 
     Square m1from = from_sq(first);
     Square m2from = from_sq(second);
index ff376386cac85dd6f3129bdbc5649f7945f8d3f8..cf0677799c6ea34b5bcf6271715ecd71bf90ca27 100644 (file)
@@ -97,7 +97,7 @@ const int MAX_PLY_PLUS_6 = MAX_PLY + 6;
 /// bit  0- 5: destination square (from 0 to 63)
 /// bit  6-11: origin square (from 0 to 63)
 /// bit 12-13: promotion piece type - 2 (from KNIGHT-2 to QUEEN-2)
 /// bit  0- 5: destination square (from 0 to 63)
 /// bit  6-11: origin square (from 0 to 63)
 /// bit 12-13: promotion piece type - 2 (from KNIGHT-2 to QUEEN-2)
-/// bit 14-15: special move flag: promotion (1), en passant (2), castle (3)
+/// bit 14-15: special move flag: promotion (1), en passant (2), castling (3)
 ///
 /// Special cases are MOVE_NONE and MOVE_NULL. We can sneak these in because in
 /// any normal move destination square is always different from origin square
 ///
 /// Special cases are MOVE_NONE and MOVE_NULL. We can sneak these in because in
 /// any normal move destination square is always different from origin square
@@ -112,17 +112,17 @@ enum MoveType {
   NORMAL,
   PROMOTION = 1 << 14,
   ENPASSANT = 2 << 14,
   NORMAL,
   PROMOTION = 1 << 14,
   ENPASSANT = 2 << 14,
-  CASTLE    = 3 << 14
+  CASTLING  = 3 << 14
 };
 
 };
 
-enum CastleRight {  // Defined as in PolyGlot book hash key
-  CASTLES_NONE,
+enum CastlingFlag {  // Defined as in PolyGlot book hash key
+  NO_CASTLING,
   WHITE_OO,
   WHITE_OOO   = WHITE_OO << 1,
   BLACK_OO    = WHITE_OO << 2,
   BLACK_OOO   = WHITE_OO << 3,
   WHITE_OO,
   WHITE_OOO   = WHITE_OO << 1,
   BLACK_OO    = WHITE_OO << 2,
   BLACK_OOO   = WHITE_OO << 3,
-  ALL_CASTLES = WHITE_OO | WHITE_OOO | BLACK_OO | BLACK_OOO,
-  CASTLE_RIGHT_NB = 16
+  ANY_CASTLING = WHITE_OO | WHITE_OOO | BLACK_OO | BLACK_OOO,
+  CASTLING_FLAG_NB = 16
 };
 
 enum CastlingSide {
 };
 
 enum CastlingSide {
@@ -346,8 +346,8 @@ inline Piece make_piece(Color c, PieceType pt) {
   return Piece((c << 3) | pt);
 }
 
   return Piece((c << 3) | pt);
 }
 
-inline CastleRight make_castle_right(Color c, CastlingSide s) {
-  return CastleRight(WHITE_OO << ((s == QUEEN_SIDE) + 2 * c));
+inline CastlingFlag make_castling_flag(Color c, CastlingSide s) {
+  return CastlingFlag(WHITE_OO << ((s == QUEEN_SIDE) + 2 * c));
 }
 
 inline PieceType type_of(Piece p)  {
 }
 
 inline PieceType type_of(Piece p)  {