movegen: refactor

This commit is contained in:
Calcitem 2020-08-30 22:10:15 +08:00
parent 8e57d6f916
commit 00e1f8d4b7
1 changed files with 13 additions and 19 deletions

View File

@ -57,25 +57,7 @@ ExtMove *generate(Position *pos, ExtMove *moveList);
/// in handy to use this class instead of the low level generate() function.
struct MoveList
{
MoveList() = delete;
MoveList &operator=(const MoveList &) = delete;
static void create();
static void shuffle();
// TODO: Move to private
inline static Move moveTable[SQUARE_NB][MD_NB] = { {MOVE_NONE} };
inline static std::array<Move, FILE_NB * RANK_NB> movePriorityTable {
(Move)8, (Move)9, (Move)10, (Move)11, (Move)12, (Move)13, (Move)14, (Move)15,
(Move)16, (Move)17, (Move)18, (Move)19, (Move)20, (Move)21, (Move)22, (Move)23,
(Move)24, (Move)25, (Move)26, (Move)27, (Move)28, (Move)29, (Move)30, (Move)31,
};
explicit MoveList(Position *pos) : last(generate(pos, moveList))
{
}
explicit MoveList(Position *pos) : last(generate(pos, moveList)) {}
const ExtMove *begin() const
{
@ -97,6 +79,18 @@ struct MoveList
return std::find(begin(), end(), move) != end();
}
static void create();
static void shuffle();
inline static std::array<Move, FILE_NB *RANK_NB> movePriorityTable {
(Move) 8, (Move) 9, (Move)10, (Move)11, (Move)12, (Move)13, (Move)14, (Move)15,
(Move)16, (Move)17, (Move)18, (Move)19, (Move)20, (Move)21, (Move)22, (Move)23,
(Move)24, (Move)25, (Move)26, (Move)27, (Move)28, (Move)29, (Move)30, (Move)31,
};
inline static Move moveTable[SQUARE_NB][MD_NB] = { {MOVE_NONE} };
private:
ExtMove moveList[MAX_MOVES], *last;
};