]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Fix bug in evaluate_passed_pawns()
[stockfish] / src / position.cpp
index 2172180cfb694783feddebd048e7546133475f98..e71499ce9b35a02177b23872b12bd8b330de5035 100644 (file)
@@ -623,7 +623,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
 
 bool Position::pl_move_is_evasion(Move m, Bitboard pinned) const
 {
-  assert(is_check());
+  assert(in_check());
 
   Color us = side_to_move();
   Square from = move_from(m);
@@ -750,18 +750,18 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
       return false;
 
   // The move is pseudo-legal, check if it is also legal
-  return is_check() ? pl_move_is_evasion(m, pinned) : pl_move_is_legal(m, pinned);
+  return in_check() ? pl_move_is_evasion(m, pinned) : pl_move_is_legal(m, pinned);
 }
 
 
-/// Position::move_is_check() tests whether a pseudo-legal move is a check
+/// Position::move_gives_check() tests whether a pseudo-legal move is a check
 
-bool Position::move_is_check(Move m) const {
+bool Position::move_gives_check(Move m) const {
 
-  return move_is_check(m, CheckInfo(*this));
+  return move_gives_check(m, CheckInfo(*this));
 }
 
-bool Position::move_is_check(Move m, const CheckInfo& ci) const {
+bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
 
   assert(is_ok());
   assert(move_is_ok(m));
@@ -853,9 +853,8 @@ bool Position::move_is_check(Move m, const CheckInfo& ci) const {
 }
 
 
-/// Position::do_setup_move() makes a permanent move on the board.
-/// It should be used when setting up a position on board.
-/// You can't undo the move.
+/// Position::do_setup_move() makes a permanent move on the board. It should
+/// be used when setting up a position on board. You can't undo the move.
 
 void Position::do_setup_move(Move m) {
 
@@ -872,18 +871,19 @@ void Position::do_setup_move(Move m) {
   startPosPlyCounter++;
 
   // Our StateInfo newSt is about going out of scope so copy
-  // its content inside pos before it disappears.
+  // its content before it disappears.
   detach();
 }
 
+
 /// Position::do_move() makes a move, and saves all information necessary
-/// to a StateInfo object. The move is assumed to be legal.
-/// Pseudo-legal moves should be filtered out before this function is called.
+/// to a StateInfo object. The move is assumed to be legal. Pseudo-legal
+/// moves should be filtered out before this function is called.
 
 void Position::do_move(Move m, StateInfo& newSt) {
 
   CheckInfo ci(*this);
-  do_move(m, newSt, ci, move_is_check(m, ci));
+  do_move(m, newSt, ci, move_gives_check(m, ci));
 }
 
 void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveIsCheck) {
@@ -1048,8 +1048,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
   }
 
   // Prefetch pawn and material hash tables
-  ThreadsMgr[threadID].pawnTable.prefetch(st->pawnKey);
-  ThreadsMgr[threadID].materialTable.prefetch(st->materialKey);
+  Threads[threadID].pawnTable.prefetch(st->pawnKey);
+  Threads[threadID].materialTable.prefetch(st->materialKey);
 
   // Update incremental scores
   st->value += pst_delta(piece, from, to);
@@ -1430,7 +1430,7 @@ void Position::undo_castle_move(Move m) {
 void Position::do_null_move(StateInfo& backupSt) {
 
   assert(is_ok());
-  assert(!is_check());
+  assert(!in_check());
 
   // Back up the information necessary to undo the null move to the supplied
   // StateInfo object.
@@ -1467,7 +1467,7 @@ void Position::do_null_move(StateInfo& backupSt) {
 void Position::undo_null_move() {
 
   assert(is_ok());
-  assert(!is_check());
+  assert(!in_check());
 
   // Restore information from the our backup StateInfo object
   StateInfo* backupSt = st->previous;
@@ -1798,7 +1798,7 @@ bool Position::is_draw() const {
 bool Position::is_mate() const {
 
   MoveStack moves[MAX_MOVES];
-  return is_check() && generate<MV_LEGAL>(*this, moves) == moves;
+  return in_check() && generate<MV_LEGAL>(*this, moves) == moves;
 }
 
 
@@ -1842,13 +1842,15 @@ void Position::init_piece_square_tables() {
 }
 
 
-/// Position::flipped_copy() makes a copy of the input position, but with
-/// the white and black sides reversed. This is only useful for debugging,
-/// especially for finding evaluation symmetry bugs.
+/// Position::flip() flips position with the white and black sides reversed. This
+/// is only useful for debugging especially for finding evaluation symmetry bugs.
+
+void Position::flip() {
 
-void Position::flipped_copy(const Position& pos) {
+  assert(is_ok());
 
-  assert(pos.is_ok());
+  // Make a copy of current position before to start changing
+  const Position pos(*this, threadID);
 
   clear();
   threadID = pos.thread();