Remove pointers, add BoardState

This commit is contained in:
2022-12-22 22:54:26 +01:00
parent 71d90918b3
commit 8d028ba087
6 changed files with 146 additions and 73 deletions

View File

@@ -6,6 +6,7 @@
#include "Move.hpp"
#include "CastlingRights.hpp"
#include "BitBoard.hpp"
#include "BoardState.hpp"
#include <optional>
#include <iosfwd>
@@ -16,18 +17,18 @@ class MoveGenerator {
public:
using MoveVec = std::vector<Move>;
MoveGenerator(const std::shared_ptr<BitBoard[]>& pieceBB, const std::shared_ptr<BitBoard>& occupiedBB);
MoveGenerator(MoveGenerator &) = delete;
MoveGenerator &operator=(MoveGenerator const &) = delete;
void generatePawnMoves(const Square &from, const std::optional<Square> &eps, PieceColor color, MoveVec &moves) const;
void generatePawnMoves(const Square &from, PieceColor color, MoveVec &moves);
static void generatePawnMoves(const BoardState &bs, const Square &from,
const std::optional<Square> &eps,
PieceColor color,
MoveVec &moves);
static void generatePawnMoves(const BoardState &bs, const Square &from, PieceColor color, MoveVec &moves);
static void generateBishopMoves(const BoardState &bs, const Square &from, PieceColor color, MoveVec &moves);
static void generateKingMoves(const BoardState &bs, const Square &from, PieceColor color, CastlingRights cr, MoveVec &moves);
static void generateRookMoves(const BoardState &bs, const Square &from, PieceColor color, MoveVec &moves);
static void generateQueenMoves(const BoardState &bs, const Square &from, PieceColor color, MoveVec &moves);
private:
const std::shared_ptr<const BitBoard[]> mPieceBBs;
const std::shared_ptr<const BitBoard> mOccupiedBB;
void generatePawnMoves(const Square &from, BitBoard targets, PieceColor color, MoveVec &moves) const;
static void generatePawnMoves(const BoardState &bs, const Square &from, BitBoard targets, PieceColor color, MoveVec &moves);
static void generateMoves(const Square &from, BitBoard movesBB, MoveVec &moves);
static void generateMovesWithPromotion(const Square &from, BitBoard movesBB, MoveVec &moves);