]> git.sesse.net Git - stockfish/commitdiff
Drop 'is' prefix from query functions
authorMarco Costalba <mcostalba@gmail.com>
Sat, 28 Sep 2013 12:43:50 +0000 (05:43 -0700)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 28 Sep 2013 13:47:59 +0000 (06:47 -0700)
Most but not all.

No functional change.

src/endgame.cpp
src/evaluate.cpp
src/movegen.cpp
src/movepick.cpp
src/notation.cpp
src/position.cpp
src/position.h
src/search.cpp
src/thread.cpp
src/thread.h

index b78d1ba909f64f19845cc29f7b4d93ea2a64be7a..b26e0a9101637a58e7299ba4c2246011bb46bee5 100644 (file)
@@ -627,8 +627,7 @@ ScaleFactor Endgame<KRPPKRP>::operator()(const Position& pos) const {
   Square bksq = pos.king_square(weakerSide);
 
   // Does the stronger side have a passed pawn?
   Square bksq = pos.king_square(weakerSide);
 
   // Does the stronger side have a passed pawn?
-  if (   pos.pawn_is_passed(strongerSide, wpsq1)
-      || pos.pawn_is_passed(strongerSide, wpsq2))
+  if (pos.pawn_passed(strongerSide, wpsq1) || pos.pawn_passed(strongerSide, wpsq2))
       return SCALE_FACTOR_NONE;
 
   Rank r = std::max(relative_rank(strongerSide, wpsq1), relative_rank(strongerSide, wpsq2));
       return SCALE_FACTOR_NONE;
 
   Rank r = std::max(relative_rank(strongerSide, wpsq1), relative_rank(strongerSide, wpsq2));
index 63c0f1f80906076b84fdddf48a1f4df51801525b..ec040f63a0bad5227e9813a9966f0b55e931e37b 100644 (file)
@@ -583,9 +583,9 @@ Value do_evaluate(const Position& pos, Value& margin) {
             const enum Piece P = make_piece(Us, PAWN);
             Square d = pawn_push(Us) + (file_of(s) == FILE_A ? DELTA_E : DELTA_W);
             if (pos.piece_on(s + d) == P)
             const enum Piece P = make_piece(Us, PAWN);
             Square d = pawn_push(Us) + (file_of(s) == FILE_A ? DELTA_E : DELTA_W);
             if (pos.piece_on(s + d) == P)
-                score -= !pos.is_empty(s + d + pawn_push(Us)) ? TrappedBishopA1H1 * 4
-                        : pos.piece_on(s + d + d) == P        ? TrappedBishopA1H1 * 2
-                                                              : TrappedBishopA1H1;
+                score -= !pos.empty(s + d + pawn_push(Us)) ? TrappedBishopA1H1 * 4
+                        : pos.piece_on(s + d + d) == P     ? TrappedBishopA1H1 * 2
+                                                           : TrappedBishopA1H1;
         }
     }
 
         }
     }
 
@@ -797,7 +797,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
     {
         Square s = pop_lsb(&b);
 
     {
         Square s = pop_lsb(&b);
 
-        assert(pos.pawn_is_passed(Us, s));
+        assert(pos.pawn_passed(Us, s));
 
         int r = int(relative_rank(Us, s) - RANK_2);
         int rr = r * (r - 1);
 
         int r = int(relative_rank(Us, s) - RANK_2);
         int rr = r * (r - 1);
@@ -819,7 +819,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
                 ebonus -= Value(square_distance(pos.king_square(Us), blockSq + pawn_push(Us)) * rr);
 
             // If the pawn is free to advance, increase bonus
                 ebonus -= Value(square_distance(pos.king_square(Us), blockSq + pawn_push(Us)) * rr);
 
             // If the pawn is free to advance, increase bonus
-            if (pos.is_empty(blockSq))
+            if (pos.empty(blockSq))
             {
                 squaresToQueen = forward_bb(Us, s);
 
             {
                 squaresToQueen = forward_bb(Us, s);
 
index fab5e46182f924118c63fe797ea9e8bb87b921a0..03bc7a09fe23175054367231a14357b25c0e213b 100644 (file)
@@ -61,7 +61,7 @@ namespace {
 
     (mlist++)->move = make<CASTLE>(kfrom, rfrom);
 
 
     (mlist++)->move = make<CASTLE>(kfrom, rfrom);
 
-    if (Checks && !pos.move_gives_check((mlist - 1)->move, CheckInfo(pos)))
+    if (Checks && !pos.gives_check((mlist - 1)->move, CheckInfo(pos)))
         mlist--;
 
     return mlist;
         mlist--;
 
     return mlist;
@@ -414,7 +414,7 @@ ExtMove* generate<LEGAL>(const Position& pos, ExtMove* mlist) {
                        : generate<NON_EVASIONS>(pos, mlist);
   while (cur != end)
       if (   (pinned || from_sq(cur->move) == ksq || type_of(cur->move) == ENPASSANT)
                        : generate<NON_EVASIONS>(pos, mlist);
   while (cur != end)
       if (   (pinned || from_sq(cur->move) == ksq || type_of(cur->move) == ENPASSANT)
-          && !pos.pl_move_is_legal(cur->move, pinned))
+          && !pos.legal(cur->move, pinned))
           cur->move = (--end)->move;
       else
           cur++;
           cur->move = (--end)->move;
       else
           cur++;
index 643c8368ca4cf1c28cbf4baa447aa88b5eb0248e..e2428554249c7a81e6cb6641ff2769715e11745f 100644 (file)
@@ -86,7 +86,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats&
   else
       stage = MAIN_SEARCH;
 
   else
       stage = MAIN_SEARCH;
 
-  ttMove = (ttm && pos.is_pseudo_legal(ttm) ? ttm : MOVE_NONE);
+  ttMove = (ttm && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE);
   end += (ttMove != MOVE_NONE);
 }
 
   end += (ttMove != MOVE_NONE);
 }
 
@@ -108,7 +108,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats&
       // Skip TT move if is not a capture or a promotion, this avoids qsearch
       // tree explosion due to a possible perpetual check or similar rare cases
       // when TT table is full.
       // Skip TT move if is not a capture or a promotion, this avoids qsearch
       // tree explosion due to a possible perpetual check or similar rare cases
       // when TT table is full.
-      if (ttm && !pos.is_capture_or_promotion(ttm))
+      if (ttm && !pos.capture_or_promotion(ttm))
           ttm = MOVE_NONE;
   }
   else
           ttm = MOVE_NONE;
   }
   else
@@ -118,7 +118,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats&
       ttm = MOVE_NONE;
   }
 
       ttm = MOVE_NONE;
   }
 
-  ttMove = (ttm && pos.is_pseudo_legal(ttm) ? ttm : MOVE_NONE);
+  ttMove = (ttm && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE);
   end += (ttMove != MOVE_NONE);
 }
 
   end += (ttMove != MOVE_NONE);
 }
 
@@ -131,9 +131,9 @@ MovePicker::MovePicker(const Position& p, Move ttm, const HistoryStats& h, Piece
 
   // In ProbCut we generate only captures better than parent's captured piece
   captureThreshold = PieceValue[MG][pt];
 
   // In ProbCut we generate only captures better than parent's captured piece
   captureThreshold = PieceValue[MG][pt];
-  ttMove = (ttm && pos.is_pseudo_legal(ttm) ? ttm : MOVE_NONE);
+  ttMove = (ttm && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE);
 
 
-  if (ttMove && (!pos.is_capture(ttMove) ||  pos.see(ttMove) <= captureThreshold))
+  if (ttMove && (!pos.capture(ttMove) || pos.see(ttMove) <= captureThreshold))
       ttMove = MOVE_NONE;
 
   end += (ttMove != MOVE_NONE);
       ttMove = MOVE_NONE;
 
   end += (ttMove != MOVE_NONE);
@@ -163,7 +163,7 @@ void MovePicker::score<CAPTURES>() {
   {
       m = it->move;
       it->score =  PieceValue[MG][pos.piece_on(to_sq(m))]
   {
       m = it->move;
       it->score =  PieceValue[MG][pos.piece_on(to_sq(m))]
-                 - type_of(pos.piece_moved(m));
+                 - type_of(pos.moved_piece(m));
 
       if (type_of(m) == PROMOTION)
           it->score += PieceValue[MG][promotion_type(m)] - PieceValue[MG][PAWN];
 
       if (type_of(m) == PROMOTION)
           it->score += PieceValue[MG][promotion_type(m)] - PieceValue[MG][PAWN];
@@ -181,7 +181,7 @@ void MovePicker::score<QUIETS>() {
   for (ExtMove* it = moves; it != end; ++it)
   {
       m = it->move;
   for (ExtMove* it = moves; it != end; ++it)
   {
       m = it->move;
-      it->score = history[pos.piece_moved(m)][to_sq(m)];
+      it->score = history[pos.moved_piece(m)][to_sq(m)];
   }
 }
 
   }
 }
 
@@ -199,11 +199,11 @@ void MovePicker::score<EVASIONS>() {
       if ((seeScore = pos.see_sign(m)) < 0)
           it->score = seeScore - HistoryStats::Max; // At the bottom
 
       if ((seeScore = pos.see_sign(m)) < 0)
           it->score = seeScore - HistoryStats::Max; // At the bottom
 
-      else if (pos.is_capture(m))
+      else if (pos.capture(m))
           it->score =  PieceValue[MG][pos.piece_on(to_sq(m))]
           it->score =  PieceValue[MG][pos.piece_on(to_sq(m))]
-                     - type_of(pos.piece_moved(m)) + HistoryStats::Max;
+                     - type_of(pos.moved_piece(m)) + HistoryStats::Max;
       else
       else
-          it->score = history[pos.piece_moved(m)][to_sq(m)];
+          it->score = history[pos.moved_piece(m)][to_sq(m)];
   }
 }
 
   }
 }
 
@@ -317,9 +317,9 @@ Move MovePicker::next_move<false>() {
       case KILLERS_S1:
           move = (cur++)->move;
           if (    move != MOVE_NONE
       case KILLERS_S1:
           move = (cur++)->move;
           if (    move != MOVE_NONE
-              &&  pos.is_pseudo_legal(move)
+              &&  pos.pseudo_legal(move)
               &&  move != ttMove
               &&  move != ttMove
-              && !pos.is_capture(move))
+              && !pos.capture(move))
               return move;
           break;
 
               return move;
           break;
 
index c96b9dbe78c1fb93fe69d67639ce4efb11f366bc..06573c78ce14424b12f00608c751f8f60095e6f8 100644 (file)
@@ -133,7 +133,7 @@ const string move_to_san(Position& pos, Move m) {
           while (b)
           {
               Move move = make_move(pop_lsb(&b), to);
           while (b)
           {
               Move move = make_move(pop_lsb(&b), to);
-              if (!pos.pl_move_is_legal(move, pos.pinned_pieces()))
+              if (!pos.legal(move, pos.pinned_pieces()))
                   others ^= from_sq(move);
           }
 
                   others ^= from_sq(move);
           }
 
@@ -149,10 +149,10 @@ const string move_to_san(Position& pos, Move m) {
                   san += square_to_string(from);
           }
       }
                   san += square_to_string(from);
           }
       }
-      else if (pos.is_capture(m))
+      else if (pos.capture(m))
           san = file_to_char(file_of(from));
 
           san = file_to_char(file_of(from));
 
-      if (pos.is_capture(m))
+      if (pos.capture(m))
           san += 'x';
 
       san += square_to_string(to);
           san += 'x';
 
       san += square_to_string(to);
@@ -161,7 +161,7 @@ const string move_to_san(Position& pos, Move m) {
           san += string("=") + PieceToChar[WHITE][promotion_type(m)];
   }
 
           san += string("=") + PieceToChar[WHITE][promotion_type(m)];
   }
 
-  if (pos.move_gives_check(m, CheckInfo(pos)))
+  if (pos.gives_check(m, CheckInfo(pos)))
   {
       StateInfo st;
       pos.do_move(m, st);
   {
       StateInfo st;
       pos.do_move(m, st);
index 4cb7e3063be940f54e919607a760d949b1130317..28b39c8d50feda128a034bfbcb8ed065a616f6a1 100644 (file)
@@ -340,11 +340,11 @@ const string Position::fen() const {
       {
           Square sq = file | rank;
 
       {
           Square sq = file | rank;
 
-          if (is_empty(sq))
+          if (empty(sq))
           {
               int emptyCnt = 1;
 
           {
               int emptyCnt = 1;
 
-              for ( ; file < FILE_H && is_empty(++sq); ++file)
+              for ( ; file < FILE_H && empty(++sq); ++file)
                   emptyCnt++;
 
               ss << emptyCnt;
                   emptyCnt++;
 
               ss << emptyCnt;
@@ -472,9 +472,9 @@ Bitboard Position::attacks_from(Piece p, Square s, Bitboard occ) {
 }
 
 
 }
 
 
-/// Position::pl_move_is_legal() tests whether a pseudo-legal move is legal
+/// Position::legal() tests whether a pseudo-legal move is legal
 
 
-bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
+bool Position::legal(Move m, Bitboard pinned) const {
 
   assert(is_ok(m));
   assert(pinned == pinned_pieces());
 
   assert(is_ok(m));
   assert(pinned == pinned_pieces());
@@ -482,7 +482,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
   Color us = sideToMove;
   Square from = from_sq(m);
 
   Color us = sideToMove;
   Square from = from_sq(m);
 
-  assert(color_of(piece_moved(m)) == us);
+  assert(color_of(moved_piece(m)) == us);
   assert(piece_on(king_square(us)) == make_piece(us, KING));
 
   // En passant captures are a tricky special case. Because they are rather
   assert(piece_on(king_square(us)) == make_piece(us, KING));
 
   // En passant captures are a tricky special case. Because they are rather
@@ -497,7 +497,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
       Bitboard b = (pieces() ^ from ^ capsq) | to;
 
       assert(to == ep_square());
       Bitboard b = (pieces() ^ from ^ capsq) | to;
 
       assert(to == ep_square());
-      assert(piece_moved(m) == make_piece(us, PAWN));
+      assert(moved_piece(m) == make_piece(us, PAWN));
       assert(piece_on(capsq) == make_piece(them, PAWN));
       assert(piece_on(to) == NO_PIECE);
 
       assert(piece_on(capsq) == make_piece(them, PAWN));
       assert(piece_on(to) == NO_PIECE);
 
@@ -519,16 +519,16 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
 }
 
 
 }
 
 
-/// Position::is_pseudo_legal() takes a random move and tests whether the move
-/// is pseudo legal. It is used to validate moves from TT that can be corrupted
+/// Position::pseudo_legal() takes a random move and tests whether the move is
+/// pseudo legal. It is used to validate moves from TT that can be corrupted
 /// due to SMP concurrent access or hash position key aliasing.
 
 /// due to SMP concurrent access or hash position key aliasing.
 
-bool Position::is_pseudo_legal(const Move m) const {
+bool Position::pseudo_legal(const Move m) const {
 
   Color us = sideToMove;
   Square from = from_sq(m);
   Square to = to_sq(m);
 
   Color us = sideToMove;
   Square from = from_sq(m);
   Square to = to_sq(m);
-  Piece pc = piece_moved(m);
+  Piece pc = moved_piece(m);
 
   // Use a slower but simpler function for uncommon cases
   if (type_of(m) != NORMAL)
 
   // Use a slower but simpler function for uncommon cases
   if (type_of(m) != NORMAL)
@@ -581,7 +581,7 @@ bool Position::is_pseudo_legal(const Move m) const {
       case DELTA_N:
       case DELTA_S:
       // Pawn push. The destination square must be empty.
       case DELTA_N:
       case DELTA_S:
       // Pawn push. The destination square must be empty.
-      if (!is_empty(to))
+      if (!empty(to))
           return false;
       break;
 
           return false;
       break;
 
@@ -590,8 +590,8 @@ bool Position::is_pseudo_legal(const Move m) const {
       // rank, and both the destination square and the square between the
       // source and destination squares must be empty.
       if (    rank_of(to) != RANK_4
       // rank, and both the destination square and the square between the
       // source and destination squares must be empty.
       if (    rank_of(to) != RANK_4
-          || !is_empty(to)
-          || !is_empty(from + DELTA_N))
+          || !empty(to)
+          || !empty(from + DELTA_N))
           return false;
       break;
 
           return false;
       break;
 
@@ -600,8 +600,8 @@ bool Position::is_pseudo_legal(const Move m) const {
       // rank, and both the destination square and the square between the
       // source and destination squares must be empty.
       if (    rank_of(to) != RANK_5
       // rank, and both the destination square and the square between the
       // source and destination squares must be empty.
       if (    rank_of(to) != RANK_5
-          || !is_empty(to)
-          || !is_empty(from + DELTA_S))
+          || !empty(to)
+          || !empty(from + DELTA_S))
           return false;
       break;
 
           return false;
       break;
 
@@ -639,11 +639,11 @@ bool Position::is_pseudo_legal(const Move m) const {
 
 /// Position::move_gives_check() tests whether a pseudo-legal move gives a check
 
 
 /// Position::move_gives_check() tests whether a pseudo-legal move gives a check
 
-bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
+bool Position::gives_check(Move m, const CheckInfo& ci) const {
 
   assert(is_ok(m));
   assert(ci.dcCandidates == discovered_check_candidates());
 
   assert(is_ok(m));
   assert(ci.dcCandidates == discovered_check_candidates());
-  assert(color_of(piece_moved(m)) == sideToMove);
+  assert(color_of(moved_piece(m)) == sideToMove);
 
   Square from = from_sq(m);
   Square to = to_sq(m);
 
   Square from = from_sq(m);
   Square to = to_sq(m);
@@ -710,7 +710,7 @@ bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
 void Position::do_move(Move m, StateInfo& newSt) {
 
   CheckInfo ci(*this);
 void Position::do_move(Move m, StateInfo& newSt) {
 
   CheckInfo ci(*this);
-  do_move(m, newSt, ci, move_gives_check(m, ci));
+  do_move(m, newSt, ci, gives_check(m, ci));
 }
 
 void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveIsCheck) {
 }
 
 void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveIsCheck) {
@@ -744,11 +744,11 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
   Square to = to_sq(m);
   Piece pc = piece_on(from);
   PieceType pt = type_of(pc);
   Square to = to_sq(m);
   Piece pc = piece_on(from);
   PieceType pt = type_of(pc);
-  PieceType capture = type_of(m) == ENPASSANT ? PAWN : type_of(piece_on(to));
+  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(color_of(pc) == us);
   assert(piece_on(to) == NO_PIECE || color_of(piece_on(to)) == them || type_of(m) == CASTLE);
-  assert(capture != KING);
+  assert(captured != KING);
 
   if (type_of(m) == CASTLE)
   {
 
   if (type_of(m) == CASTLE)
   {
@@ -758,7 +758,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
       Square rfrom = to; // Castle 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);
       Square rfrom = to; // Castle 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);
-      capture = NO_PIECE_TYPE;
+      captured = NO_PIECE_TYPE;
 
       do_castle(from, to, rfrom, rto);
 
 
       do_castle(from, to, rfrom, rto);
 
@@ -766,13 +766,13 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
       k ^= Zobrist::psq[us][ROOK][rfrom] ^ Zobrist::psq[us][ROOK][rto];
   }
 
       k ^= Zobrist::psq[us][ROOK][rfrom] ^ Zobrist::psq[us][ROOK][rto];
   }
 
-  if (capture)
+  if (captured)
   {
       Square capsq = to;
 
       // If the captured piece is a pawn, update pawn hash key, otherwise
       // update non-pawn material.
   {
       Square capsq = to;
 
       // If the captured piece is a pawn, update pawn hash key, otherwise
       // update non-pawn material.
-      if (capture == PAWN)
+      if (captured == PAWN)
       {
           if (type_of(m) == ENPASSANT)
           {
       {
           if (type_of(m) == ENPASSANT)
           {
@@ -790,18 +790,18 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
           st->pawnKey ^= Zobrist::psq[them][PAWN][capsq];
       }
       else
           st->pawnKey ^= Zobrist::psq[them][PAWN][capsq];
       }
       else
-          st->npMaterial[them] -= PieceValue[MG][capture];
+          st->npMaterial[them] -= PieceValue[MG][captured];
 
       // Update board and piece lists
 
       // Update board and piece lists
-      remove_piece(capsq, them, capture);
+      remove_piece(capsq, them, captured);
 
       // Update material hash key and prefetch access to materialTable
 
       // Update material hash key and prefetch access to materialTable
-      k ^= Zobrist::psq[them][capture][capsq];
-      st->materialKey ^= Zobrist::psq[them][capture][pieceCount[them][capture]];
+      k ^= Zobrist::psq[them][captured][capsq];
+      st->materialKey ^= Zobrist::psq[them][captured][pieceCount[them][captured]];
       prefetch((char*)thisThread->materialTable[st->materialKey]);
 
       // Update incremental scores
       prefetch((char*)thisThread->materialTable[st->materialKey]);
 
       // Update incremental scores
-      st->psq -= psq[them][capture][capsq];
+      st->psq -= psq[them][captured][capsq];
 
       // Reset rule 50 counter
       st->rule50 = 0;
 
       // Reset rule 50 counter
       st->rule50 = 0;
@@ -878,7 +878,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
   st->psq += psq[us][pt][to] - psq[us][pt][from];
 
   // Set capture piece
   st->psq += psq[us][pt][to] - psq[us][pt][from];
 
   // Set capture piece
-  st->capturedType = capture;
+  st->capturedType = captured;
 
   // Update the key with the final value
   st->key = k;
 
   // Update the key with the final value
   st->key = k;
@@ -928,10 +928,10 @@ void Position::undo_move(Move m) {
   Square from = from_sq(m);
   Square to = to_sq(m);
   PieceType pt = type_of(piece_on(to));
   Square from = from_sq(m);
   Square to = to_sq(m);
   PieceType pt = type_of(piece_on(to));
-  PieceType capture = st->capturedType;
+  PieceType captured = st->capturedType;
 
 
-  assert(is_empty(from) || type_of(m) == CASTLE);
-  assert(capture != KING);
+  assert(empty(from) || type_of(m) == CASTLE);
+  assert(captured != KING);
 
   if (type_of(m) == PROMOTION)
   {
 
   if (type_of(m) == PROMOTION)
   {
@@ -952,14 +952,14 @@ void Position::undo_move(Move m) {
       Square rfrom = to; // Castle 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);
       Square rfrom = to; // Castle 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);
-      capture = NO_PIECE_TYPE;
+      captured = NO_PIECE_TYPE;
       pt = KING;
       do_castle(to, from, rto, rfrom);
   }
   else
       move_piece(to, from, us, pt); // Put the piece back at the source square
 
       pt = KING;
       do_castle(to, from, rto, rfrom);
   }
   else
       move_piece(to, from, us, pt); // Put the piece back at the source square
 
-  if (capture)
+  if (captured)
   {
       Square capsq = to;
 
   {
       Square capsq = to;
 
@@ -973,7 +973,7 @@ void Position::undo_move(Move m) {
           assert(piece_on(capsq) == NO_PIECE);
       }
 
           assert(piece_on(capsq) == NO_PIECE);
       }
 
-      put_piece(capsq, them, capture); // Restore the captured piece
+      put_piece(capsq, them, captured); // Restore the captured piece
   }
 
   // Finally point our state pointer back to the previous state
   }
 
   // Finally point our state pointer back to the previous state
@@ -1049,7 +1049,7 @@ int Position::see_sign(Move m) const {
   // Early return if SEE cannot be negative because captured piece value
   // is not less then capturing one. Note that king moves always return
   // here because king midgame value is set to 0.
   // Early return if SEE cannot be negative because captured piece value
   // is not less then capturing one. Note that king moves always return
   // here because king midgame value is set to 0.
-  if (PieceValue[MG][piece_moved(m)] <= PieceValue[MG][piece_on(to_sq(m))])
+  if (PieceValue[MG][moved_piece(m)] <= PieceValue[MG][piece_on(to_sq(m))])
       return 1;
 
   return see(m);
       return 1;
 
   return see(m);
index bf387dc6f1d848e84fff0eac5994c9b9c7adcff6..9dd9e79e97f8a7d99f4088e469833ccc766b6366 100644 (file)
@@ -43,10 +43,10 @@ struct CheckInfo {
 };
 
 
 };
 
 
-/// The StateInfo struct stores information we need to restore a Position
+/// The StateInfo struct stores information needed to restore a Position
 /// object to its previous state when we retract a move. Whenever a move
 /// object to its previous state when we retract a move. Whenever a move
-/// is made on the board (by calling Position::do_move), a StateInfo object
-/// must be passed as a parameter.
+/// is made on the board (by calling Position::do_move), a StateInfo
+/// object must be passed as a parameter.
 
 struct StateInfo {
   Key pawnKey, materialKey;
 
 struct StateInfo {
   Key pawnKey, materialKey;
@@ -67,27 +67,10 @@ struct StateInfo {
 const size_t StateCopySize64 = offsetof(StateInfo, key) / sizeof(uint64_t) + 1;
 
 
 const size_t StateCopySize64 = offsetof(StateInfo, key) / sizeof(uint64_t) + 1;
 
 
-/// The position data structure. A position consists of the following data:
-///
-///    * For each piece type, a bitboard representing the squares occupied
-///      by pieces of that type.
-///    * For each color, a bitboard representing the squares occupied by
-///      pieces of that color.
-///    * A bitboard of all occupied squares.
-///    * A bitboard of all checking pieces.
-///    * A 64-entry array of pieces, indexed by the squares of the board.
-///    * The current side to move.
-///    * Information about the castling rights for both sides.
-///    * The initial files of the kings and both pairs of rooks. This is
-///      used to implement the Chess960 castling rules.
-///    * The en passant square (which is SQ_NONE if no en passant capture is
-///      possible).
-///    * The squares of the kings for both sides.
-///    * Hash keys for the position itself, the current pawn structure, and
-///      the current material situation.
-///    * Hash keys for all previous positions in the game for detecting
-///      repetition draws.
-///    * A counter for detecting 50 move rule draws.
+/// The Position class stores the information regarding the board representation
+/// like pieces, side to move, hash keys, castling info, etc. The most important
+/// methods are do_move() and undo_move(), used by the search to update node info
+/// when traversing the search tree.
 
 class Position {
 public:
 
 class Position {
 public:
@@ -112,7 +95,7 @@ public:
   Piece piece_on(Square s) const;
   Square king_square(Color c) const;
   Square ep_square() const;
   Piece piece_on(Square s) const;
   Square king_square(Color c) const;
   Square ep_square() const;
-  bool is_empty(Square s) const;
+  bool empty(Square s) const;
   template<PieceType Pt> int count(Color c) const;
   template<PieceType Pt> const Square* list(Color c) const;
 
   template<PieceType Pt> int count(Color c) const;
   template<PieceType Pt> const Square* list(Color c) const;
 
@@ -136,20 +119,20 @@ public:
   template<PieceType> Bitboard attacks_from(Square s, Color c) const;
 
   // Properties of moves
   template<PieceType> Bitboard attacks_from(Square s, Color c) const;
 
   // Properties of moves
-  bool move_gives_check(Move m, const CheckInfo& ci) const;
-  bool pl_move_is_legal(Move m, Bitboard pinned) const;
-  bool is_pseudo_legal(const Move m) const;
-  bool is_capture(Move m) const;
-  bool is_capture_or_promotion(Move m) const;
-  bool is_passed_pawn_push(Move m) const;
-  Piece piece_moved(Move m) const;
+  bool legal(Move m, Bitboard pinned) const;
+  bool pseudo_legal(const Move m) const;
+  bool capture(Move m) const;
+  bool capture_or_promotion(Move m) const;
+  bool gives_check(Move m, const CheckInfo& ci) const;
+  bool passed_pawn_push(Move m) const;
+  Piece moved_piece(Move m) const;
   PieceType captured_piece_type() const;
 
   // Piece specific
   PieceType captured_piece_type() const;
 
   // Piece specific
-  bool pawn_is_passed(Color c, Square s) const;
+  bool pawn_passed(Color c, Square s) const;
   bool pawn_on_7th(Color c) const;
   bool pawn_on_7th(Color c) const;
-  bool opposite_bishops() const;
   bool bishop_pair(Color c) const;
   bool bishop_pair(Color c) const;
+  bool opposite_bishops() const;
 
   // Doing and undoing moves
   void do_move(Move m, StateInfo& st);
 
   // Doing and undoing moves
   void do_move(Move m, StateInfo& st);
@@ -239,11 +222,11 @@ inline Piece Position::piece_on(Square s) const {
   return board[s];
 }
 
   return board[s];
 }
 
-inline Piece Position::piece_moved(Move m) const {
+inline Piece Position::moved_piece(Move m) const {
   return board[from_sq(m)];
 }
 
   return board[from_sq(m)];
 }
 
-inline bool Position::is_empty(Square s) const {
+inline bool Position::empty(Square s) const {
   return board[s] == NO_PIECE;
 }
 
   return board[s] == NO_PIECE;
 }
 
@@ -340,10 +323,16 @@ inline Bitboard Position::pinned_pieces() const {
   return hidden_checkers(king_square(sideToMove), ~sideToMove);
 }
 
   return hidden_checkers(king_square(sideToMove), ~sideToMove);
 }
 
-inline bool Position::pawn_is_passed(Color c, Square s) const {
+inline bool Position::pawn_passed(Color c, Square s) const {
   return !(pieces(~c, PAWN) & passed_pawn_mask(c, s));
 }
 
   return !(pieces(~c, PAWN) & passed_pawn_mask(c, s));
 }
 
+inline bool Position::passed_pawn_push(Move m) const {
+
+  return   type_of(moved_piece(m)) == PAWN
+        && pawn_passed(sideToMove, to_sq(m));
+}
+
 inline Key Position::key() const {
   return st->key;
 }
 inline Key Position::key() const {
   return st->key;
 }
@@ -364,12 +353,6 @@ inline Value Position::non_pawn_material(Color c) const {
   return st->npMaterial[c];
 }
 
   return st->npMaterial[c];
 }
 
-inline bool Position::is_passed_pawn_push(Move m) const {
-
-  return   type_of(piece_moved(m)) == PAWN
-        && pawn_is_passed(sideToMove, to_sq(m));
-}
-
 inline int Position::game_ply() const {
   return gamePly;
 }
 inline int Position::game_ply() const {
   return gamePly;
 }
@@ -395,17 +378,17 @@ inline bool Position::is_chess960() const {
   return chess960;
 }
 
   return chess960;
 }
 
-inline bool Position::is_capture_or_promotion(Move m) const {
+inline bool Position::capture_or_promotion(Move m) const {
 
   assert(is_ok(m));
 
   assert(is_ok(m));
-  return type_of(m) ? type_of(m) != CASTLE : !is_empty(to_sq(m));
+  return type_of(m) ? type_of(m) != CASTLE : !empty(to_sq(m));
 }
 
 }
 
-inline bool Position::is_capture(Move m) const {
+inline bool Position::capture(Move m) const {
 
   // Note that castle is coded as "king captures the rook"
   assert(is_ok(m));
 
   // Note that castle is coded as "king captures the rook"
   assert(is_ok(m));
-  return (!is_empty(to_sq(m)) && type_of(m) != CASTLE) || type_of(m) == ENPASSANT;
+  return (!empty(to_sq(m)) && type_of(m) != CASTLE) || type_of(m) == ENPASSANT;
 }
 
 inline PieceType Position::captured_piece_type() const {
 }
 
 inline PieceType Position::captured_piece_type() const {
index 789492fd95225965194b8262affc992978ea53de..5ef8bc7fbdd9571962138d8c751af038c9aec0ac 100644 (file)
@@ -170,7 +170,7 @@ static size_t perft(Position& pos, Depth depth) {
 
   for (MoveList<LEGAL> it(pos); *it; ++it)
   {
 
   for (MoveList<LEGAL> it(pos); *it; ++it)
   {
-      pos.do_move(*it, st, ci, pos.move_gives_check(*it, ci));
+      pos.do_move(*it, st, ci, pos.gives_check(*it, ci));
       cnt += leaf ? MoveList<LEGAL>(pos).size() : ::perft(pos, depth - ONE_PLY);
       pos.undo_move(*it);
   }
       cnt += leaf ? MoveList<LEGAL>(pos).size() : ::perft(pos, depth - ONE_PLY);
       pos.undo_move(*it);
   }
@@ -584,7 +584,7 @@ namespace {
 
         if (    ttValue >= beta
             &&  ttMove
 
         if (    ttValue >= beta
             &&  ttMove
-            && !pos.is_capture_or_promotion(ttMove)
+            && !pos.capture_or_promotion(ttMove)
             &&  ttMove != ss->killers[0])
         {
             ss->killers[1] = ss->killers[0];
             &&  ttMove != ss->killers[0])
         {
             ss->killers[1] = ss->killers[0];
@@ -738,10 +738,10 @@ namespace {
         CheckInfo ci(pos);
 
         while ((move = mp.next_move<false>()) != MOVE_NONE)
         CheckInfo ci(pos);
 
         while ((move = mp.next_move<false>()) != MOVE_NONE)
-            if (pos.pl_move_is_legal(move, ci.pinned))
+            if (pos.legal(move, ci.pinned))
             {
                 ss->currentMove = move;
             {
                 ss->currentMove = move;
-                pos.do_move(move, st, ci, pos.move_gives_check(move, ci));
+                pos.do_move(move, st, ci, pos.gives_check(move, ci));
                 value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, rdepth, !cutNode);
                 pos.undo_move(move);
                 if (value >= rbeta)
                 value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, rdepth, !cutNode);
                 pos.undo_move(move);
                 if (value >= rbeta)
@@ -803,7 +803,7 @@ moves_loop: // When in check and at SpNode search starts from here
       if (SpNode)
       {
           // Shared counter cannot be decremented later if move turns out to be illegal
       if (SpNode)
       {
           // Shared counter cannot be decremented later if move turns out to be illegal
-          if (!pos.pl_move_is_legal(move, ci.pinned))
+          if (!pos.legal(move, ci.pinned))
               continue;
 
           moveCount = ++splitPoint->moveCount;
               continue;
 
           moveCount = ++splitPoint->moveCount;
@@ -823,10 +823,10 @@ moves_loop: // When in check and at SpNode search starts from here
       }
 
       ext = DEPTH_ZERO;
       }
 
       ext = DEPTH_ZERO;
-      captureOrPromotion = pos.is_capture_or_promotion(move);
-      givesCheck = pos.move_gives_check(move, ci);
+      captureOrPromotion = pos.capture_or_promotion(move);
+      givesCheck = pos.gives_check(move, ci);
       dangerous =   givesCheck
       dangerous =   givesCheck
-                 || pos.is_passed_pawn_push(move)
+                 || pos.passed_pawn_push(move)
                  || type_of(move) == CASTLE;
 
       // Step 12. Extend checks
                  || type_of(move) == CASTLE;
 
       // Step 12. Extend checks
@@ -841,7 +841,7 @@ moves_loop: // When in check and at SpNode search starts from here
       if (    singularExtensionNode
           &&  move == ttMove
           && !ext
       if (    singularExtensionNode
           &&  move == ttMove
           && !ext
-          &&  pos.pl_move_is_legal(move, ci.pinned)
+          &&  pos.legal(move, ci.pinned)
           &&  abs(ttValue) < VALUE_KNOWN_WIN)
       {
           assert(ttValue != VALUE_NONE);
           &&  abs(ttValue) < VALUE_KNOWN_WIN)
       {
           assert(ttValue != VALUE_NONE);
@@ -884,7 +884,7 @@ moves_loop: // When in check and at SpNode search starts from here
           // but fixing this made program slightly weaker.
           Depth predictedDepth = newDepth - reduction<PvNode>(improving, depth, moveCount);
           futilityValue =  ss->staticEval + ss->evalMargin + futility_margin(predictedDepth, moveCount)
           // but fixing this made program slightly weaker.
           Depth predictedDepth = newDepth - reduction<PvNode>(improving, depth, moveCount);
           futilityValue =  ss->staticEval + ss->evalMargin + futility_margin(predictedDepth, moveCount)
-                         + Gains[pos.piece_moved(move)][to_sq(move)];
+                         + Gains[pos.moved_piece(move)][to_sq(move)];
 
           if (futilityValue < beta)
           {
 
           if (futilityValue < beta)
           {
@@ -917,7 +917,7 @@ moves_loop: // When in check and at SpNode search starts from here
           ss->futilityMoveCount = 0;
 
       // Check for legality only before to do the move
           ss->futilityMoveCount = 0;
 
       // Check for legality only before to do the move
-      if (!RootNode && !SpNode && !pos.pl_move_is_legal(move, ci.pinned))
+      if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
       {
           moveCount--;
           continue;
       {
           moveCount--;
           continue;
@@ -1088,7 +1088,7 @@ moves_loop: // When in check and at SpNode search starts from here
 
     // Quiet best move: update killers, history and countermoves
     if (    bestValue >= beta
 
     // Quiet best move: update killers, history and countermoves
     if (    bestValue >= beta
-        && !pos.is_capture_or_promotion(bestMove)
+        && !pos.capture_or_promotion(bestMove)
         && !inCheck)
     {
         if (ss->killers[0] != bestMove)
         && !inCheck)
     {
         if (ss->killers[0] != bestMove)
@@ -1100,11 +1100,11 @@ moves_loop: // When in check and at SpNode search starts from here
         // Increase history value of the cut-off move and decrease all the other
         // played non-capture moves.
         Value bonus = Value(int(depth) * int(depth));
         // Increase history value of the cut-off move and decrease all the other
         // played non-capture moves.
         Value bonus = Value(int(depth) * int(depth));
-        History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
+        History.update(pos.moved_piece(bestMove), to_sq(bestMove), bonus);
         for (int i = 0; i < quietCount - 1; ++i)
         {
             Move m = quietsSearched[i];
         for (int i = 0; i < quietCount - 1; ++i)
         {
             Move m = quietsSearched[i];
-            History.update(pos.piece_moved(m), to_sq(m), -bonus);
+            History.update(pos.moved_piece(m), to_sq(m), -bonus);
         }
 
         if (is_ok((ss-1)->currentMove))
         }
 
         if (is_ok((ss-1)->currentMove))
@@ -1220,7 +1220,7 @@ moves_loop: // When in check and at SpNode search starts from here
     {
       assert(is_ok(move));
 
     {
       assert(is_ok(move));
 
-      givesCheck = pos.move_gives_check(move, ci);
+      givesCheck = pos.gives_check(move, ci);
 
       // Futility pruning
       if (   !PvNode
 
       // Futility pruning
       if (   !PvNode
@@ -1229,7 +1229,7 @@ moves_loop: // When in check and at SpNode search starts from here
           &&  move != ttMove
           &&  type_of(move) != PROMOTION
           &&  futilityBase > -VALUE_KNOWN_WIN
           &&  move != ttMove
           &&  type_of(move) != PROMOTION
           &&  futilityBase > -VALUE_KNOWN_WIN
-          && !pos.is_passed_pawn_push(move))
+          && !pos.passed_pawn_push(move))
       {
           futilityValue =  futilityBase
                          + PieceValue[EG][pos.piece_on(to_sq(move))]
       {
           futilityValue =  futilityBase
                          + PieceValue[EG][pos.piece_on(to_sq(move))]
@@ -1254,7 +1254,7 @@ moves_loop: // When in check and at SpNode search starts from here
       // Detect non-capture evasions that are candidate to be pruned
       evasionPrunable =    InCheck
                        &&  bestValue > VALUE_MATED_IN_MAX_PLY
       // Detect non-capture evasions that are candidate to be pruned
       evasionPrunable =    InCheck
                        &&  bestValue > VALUE_MATED_IN_MAX_PLY
-                       && !pos.is_capture(move)
+                       && !pos.capture(move)
                        && !pos.can_castle(pos.side_to_move());
 
       // Don't search moves with negative SEE values
                        && !pos.can_castle(pos.side_to_move());
 
       // Don't search moves with negative SEE values
@@ -1266,7 +1266,7 @@ moves_loop: // When in check and at SpNode search starts from here
           continue;
 
       // Check for legality only before to do the move
           continue;
 
       // Check for legality only before to do the move
-      if (!pos.pl_move_is_legal(move, ci.pinned))
+      if (!pos.legal(move, ci.pinned))
           continue;
 
       ss->currentMove = move;
           continue;
 
       ss->currentMove = move;
@@ -1406,7 +1406,7 @@ moves_loop: // When in check and at SpNode search starts from here
 
     // If the threatened piece has value less than or equal to the value of the
     // threat piece, don't prune moves which defend it.
 
     // If the threatened piece has value less than or equal to the value of the
     // threat piece, don't prune moves which defend it.
-    if (    pos.is_capture(second)
+    if (    pos.capture(second)
         && (   PieceValue[MG][pos.piece_on(m2from)] >= PieceValue[MG][pos.piece_on(m2to)]
             || type_of(pos.piece_on(m2from)) == KING))
     {
         && (   PieceValue[MG][pos.piece_on(m2from)] >= PieceValue[MG][pos.piece_on(m2to)]
             || type_of(pos.piece_on(m2from)) == KING))
     {
@@ -1547,8 +1547,8 @@ void RootMove::extract_pv_from_tt(Position& pos) {
       tte = TT.probe(pos.key());
 
   } while (   tte
       tte = TT.probe(pos.key());
 
   } while (   tte
-           && pos.is_pseudo_legal(m = tte->move()) // Local copy, TT could change
-           && pos.pl_move_is_legal(m, pos.pinned_pieces())
+           && pos.pseudo_legal(m = tte->move()) // Local copy, TT could change
+           && pos.legal(m, pos.pinned_pieces())
            && ply < MAX_PLY
            && (!pos.is_draw() || ply < 2));
 
            && ply < MAX_PLY
            && (!pos.is_draw() || ply < 2));
 
index 7d85db8618ca982059b96466d963e29d3b1b5ba7..782537d765dd6c567c22883b42764e38cb74a479 100644 (file)
@@ -157,14 +157,14 @@ bool Thread::cutoff_occurred() const {
 }
 
 
 }
 
 
-// Thread::is_available_to() checks whether the thread is available to help the
+// Thread::available_to() checks whether the thread is available to help the
 // thread 'master' at a split point. An obvious requirement is that thread must
 // be idle. With more than two threads, this is not sufficient: If the thread is
 // the master of some split point, it is only available as a slave to the slaves
 // which are busy searching the split point at the top of slaves split point
 // stack (the "helpful master concept" in YBWC terminology).
 
 // thread 'master' at a split point. An obvious requirement is that thread must
 // be idle. With more than two threads, this is not sufficient: If the thread is
 // the master of some split point, it is only available as a slave to the slaves
 // which are busy searching the split point at the top of slaves split point
 // stack (the "helpful master concept" in YBWC terminology).
 
-bool Thread::is_available_to(const Thread* master) const {
+bool Thread::available_to(const Thread* master) const {
 
   if (searching)
       return false;
 
   if (searching)
       return false;
@@ -241,7 +241,7 @@ void ThreadPool::read_uci_options() {
 Thread* ThreadPool::available_slave(const Thread* master) const {
 
   for (const_iterator it = begin(); it != end(); ++it)
 Thread* ThreadPool::available_slave(const Thread* master) const {
 
   for (const_iterator it = begin(); it != end(); ++it)
-      if ((*it)->is_available_to(master))
+      if ((*it)->available_to(master))
           return *it;
 
   return NULL;
           return *it;
 
   return NULL;
@@ -330,7 +330,7 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu
 
       // We have returned from the idle loop, which means that all threads are
       // finished. Note that setting 'searching' and decreasing splitPointsSize is
 
       // We have returned from the idle loop, which means that all threads are
       // finished. Note that setting 'searching' and decreasing splitPointsSize is
-      // done under lock protection to avoid a race with Thread::is_available_to().
+      // done under lock protection to avoid a race with Thread::available_to().
       Threads.mutex.lock();
       sp.mutex.lock();
   }
       Threads.mutex.lock();
       sp.mutex.lock();
   }
index 56d000f3f94438275a83c88eb06ad7c2582fd921..d3dd18679b2a2b9b143caee5cfab79d166094aea 100644 (file)
@@ -114,7 +114,7 @@ struct Thread : public ThreadBase {
   Thread();
   virtual void idle_loop();
   bool cutoff_occurred() const;
   Thread();
   virtual void idle_loop();
   bool cutoff_occurred() const;
-  bool is_available_to(const Thread* master) const;
+  bool available_to(const Thread* master) const;
 
   template <bool Fake>
   void split(Position& pos, const Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,
 
   template <bool Fake>
   void split(Position& pos, const Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,