diff --git a/src/movegen.h b/src/movegen.h index 656aced2f..c9b49740d 100644 --- a/src/movegen.h +++ b/src/movegen.h @@ -128,24 +128,21 @@ ExtMove* generate(const Position& pos, ExtMove* moveList); extern movelist_buf mlb[8]; -movelist_buf& get_thread_mlb( const Position& pos ); - - /// The MoveList struct is a simple wrapper around generate(). It sometimes comes /// in handy to use this class instead of the low level generate() function. template struct MoveList { explicit MoveList(const Position& pos) - :mlb_(get_thread_mlb(pos)) { - this->moveList = mlb_.acquire(); + this->thread_id = get_thread_id(pos); + this->moveList = mlb[thread_id].acquire(); this->last = generate(pos, this->moveList); } ~MoveList() { - mlb_.release(this->moveList); + mlb[thread_id].release(this->moveList); } const ExtMove* begin() const { return moveList; } @@ -156,7 +153,7 @@ struct MoveList { } private: - movelist_buf& mlb_; + size_t thread_id; ExtMove* last; ExtMove* moveList = nullptr; }; diff --git a/src/position.cpp b/src/position.cpp index ac9b385c6..ec0764bbc 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -151,11 +151,6 @@ size_t get_thread_id( const Position& pos ) return pos.this_thread()->id(); } -movelist_buf& get_thread_mlb( const Position& pos ) -{ - return mlb[pos.this_thread()->id()]; -} - /// Position::init() initializes at startup the various arrays used to compute hash keys void Position::init() { @@ -2857,7 +2852,7 @@ bool Position::is_immediate_game_end(Value& result, int ply) const { current |= newBitboard; } } - + if (connect_nxn()) { Bitboard connectors = connectPieces; diff --git a/src/position.h b/src/position.h index 8b43b61dd..d0d20509a 100644 --- a/src/position.h +++ b/src/position.h @@ -992,11 +992,11 @@ inline bool Position::flag_move() const { inline bool Position::flag_reached(Color c) const { assert(var != nullptr); - bool simpleResult = + bool simpleResult = (flag_region(c) & pieces(c, flag_piece(c))) && ( popcount(flag_region(c) & pieces(c, flag_piece(c))) >= var->flagPieceCount || (var->flagPieceBlockedWin && !(flag_region(c) & ~pieces()))); - + if (simpleResult&&var->flagPieceSafe) { Bitboard piecesInFlagZone = flag_region(c) & pieces(c, flag_piece(c)); @@ -1006,7 +1006,7 @@ inline bool Position::flag_reached(Color c) const { pieces in the flag zone and they need to be safe: If I have 3 pieces there, but one is under threat, I don't think I can declare victory. If I have 4 there, but one is under threat, I think that's victory. - */ + */ while (piecesInFlagZone) { Square sr = pop_lsb(piecesInFlagZone); @@ -1417,7 +1417,6 @@ inline const std::string Position::piece_to_partner() const { } size_t get_thread_id( const Position& pos ); -movelist_buf& get_thread_mlb( const Position& pos ); inline Thread* Position::this_thread() const { return thisThread;