X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=9f9069cdf67c318264353bb73e5f9d0d317c6627;hb=bb7713c8e92c9373f0294a4317101cccda0e17e5;hp=e3bf4aee3e17863c55ca862ff15607443d395512;hpb=54f1c383d36f461a740eeaa93856b408e8d3faa3;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index e3bf4aee..9f9069cd 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -29,6 +29,7 @@ #include "position.h" #include "psqtab.h" #include "rkiss.h" +#include "thread.h" #include "tt.h" #include "ucioption.h" @@ -649,7 +650,7 @@ bool Position::pl_move_is_evasion(Move m, Bitboard pinned) const bool Position::move_is_legal(const Move m) const { - MoveStack mlist[MOVES_MAX]; + MoveStack mlist[MAX_MOVES]; MoveStack *cur, *last = generate(*this, mlist); for (cur = mlist; cur != last; cur++) @@ -852,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) { @@ -871,13 +871,14 @@ 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) { @@ -1047,7 +1048,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI } // Prefetch pawn and material hash tables - prefetchTables(st->pawnKey, st->materialKey, threadID); + Threads[threadID].pawnTable.prefetch(st->pawnKey); + Threads[threadID].materialTable.prefetch(st->materialKey); // Update incremental scores st->value += pst_delta(piece, from, to); @@ -1795,7 +1797,7 @@ bool Position::is_draw() const { bool Position::is_mate() const { - MoveStack moves[MOVES_MAX]; + MoveStack moves[MAX_MOVES]; return is_check() && generate(*this, moves) == moves; } @@ -1840,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();