Skip to content

Commit

Permalink
Reorganised MoveList.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpldgr committed Nov 26, 2024
1 parent 9da5633 commit a5a8c7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
20 changes: 0 additions & 20 deletions src/movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@ void movelist_buf::mlb_shutdown()
}
}

template<GenType T>
MoveList<T>::MoveList(const Position& pos)
{
this->mlb = get_thread_mlb(pos);
this->moveList = this->mlb->acquire();
this->last = generate<T>(pos, this->moveList);
}

template<GenType T>
MoveList<T>::~MoveList()
{
this->mlb->release(this->moveList);
}

namespace {

template<MoveType T>
Expand Down Expand Up @@ -541,12 +527,6 @@ template ExtMove* generate<QUIETS>(const Position&, ExtMove*);
template ExtMove* generate<EVASIONS>(const Position&, ExtMove*);
template ExtMove* generate<QUIET_CHECKS>(const Position&, ExtMove*);
template ExtMove* generate<NON_EVASIONS>(const Position&, ExtMove*);
template struct MoveList<CAPTURES>;
template struct MoveList<QUIETS>;
template struct MoveList<EVASIONS>;
template struct MoveList<QUIET_CHECKS>;
template struct MoveList<NON_EVASIONS>;
template struct MoveList<LEGAL>;

/// generate<LEGAL> generates all the legal moves in the given position

Expand Down
17 changes: 14 additions & 3 deletions src/movegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace Stockfish {
class Position;
class movelist_buf;

movelist_buf* get_thread_mlb( const Position& pos );

enum GenType {
CAPTURES,
QUIETS,
Expand Down Expand Up @@ -144,8 +146,18 @@ ExtMove* generate(const Position& pos, ExtMove* moveList);
template<GenType T>
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<T>(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; }
Expand All @@ -159,7 +171,6 @@ struct MoveList {
ExtMove* moveList = nullptr;
};

movelist_buf* get_thread_mlb( const Position& pos );
} // namespace Stockfish


Expand Down

0 comments on commit a5a8c7e

Please sign in to comment.