From a5a8c7eff0f15fb5a7909fb5a8ed8886f1ea24cb Mon Sep 17 00:00:00 2001 From: dpldgr <144766863+dpldgr@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:21:27 +0800 Subject: [PATCH] Reorganised MoveList. --- src/movegen.cpp | 20 -------------------- src/movegen.h | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/movegen.cpp b/src/movegen.cpp index eed551e0a..c3be5e001 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -48,20 +48,6 @@ void movelist_buf::mlb_shutdown() } } -template -MoveList::MoveList(const Position& pos) -{ - this->mlb = get_thread_mlb(pos); - this->moveList = this->mlb->acquire(); - this->last = generate(pos, this->moveList); -} - -template -MoveList::~MoveList() -{ - this->mlb->release(this->moveList); -} - namespace { template @@ -541,12 +527,6 @@ template ExtMove* generate(const Position&, ExtMove*); template ExtMove* generate(const Position&, ExtMove*); template ExtMove* generate(const Position&, ExtMove*); template ExtMove* generate(const Position&, ExtMove*); -template struct MoveList; -template struct MoveList; -template struct MoveList; -template struct MoveList; -template struct MoveList; -template struct MoveList; /// generate generates all the legal moves in the given position diff --git a/src/movegen.h b/src/movegen.h index 8990cf1a0..a92c423ac 100644 --- a/src/movegen.h +++ b/src/movegen.h @@ -28,6 +28,8 @@ namespace Stockfish { class Position; class movelist_buf; +movelist_buf* get_thread_mlb( const Position& pos ); + enum GenType { CAPTURES, QUIETS, @@ -144,8 +146,18 @@ ExtMove* generate(const Position& pos, ExtMove* moveList); template struct MoveList { - explicit MoveList(const Position& pos); - ~MoveList(); + explicit MoveList(const Position& pos) + { + this->mlb = get_thread_mlb(pos); + this->moveList = this->mlb->acquire(); + this->last = generate(pos, this->moveList); + } + + ~MoveList() + { + this->mlb->release(this->moveList); + } + const ExtMove* begin() const { return moveList; } const ExtMove* end() const { return last; } size_t size() const { return last - moveList; } @@ -159,7 +171,6 @@ struct MoveList { ExtMove* moveList = nullptr; }; -movelist_buf* get_thread_mlb( const Position& pos ); } // namespace Stockfish