Skip to content

Commit

Permalink
Revert "Test using ref to movelist_buf"
Browse files Browse the repository at this point in the history
This reverts commit 8bb1934.
  • Loading branch information
dpldgr committed Nov 22, 2024
1 parent 8bb1934 commit f030d0a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
11 changes: 4 additions & 7 deletions src/movegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<GenType T>
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<T>(pos, this->moveList);
}

~MoveList()
{
mlb_.release(this->moveList);
mlb[thread_id].release(this->moveList);
}

const ExtMove* begin() const { return moveList; }
Expand All @@ -156,7 +153,7 @@ struct MoveList {
}

private:
movelist_buf& mlb_;
size_t thread_id;
ExtMove* last;
ExtMove* moveList = nullptr;
};
Expand Down
7 changes: 1 addition & 6 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -2857,7 +2852,7 @@ bool Position::is_immediate_game_end(Value& result, int ply) const {
current |= newBitboard;
}
}

if (connect_nxn())
{
Bitboard connectors = connectPieces;
Expand Down
7 changes: 3 additions & 4 deletions src/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f030d0a

Please sign in to comment.