|
@@ -7,12 +7,58 @@ template class PawnPushGenerator<WHITE_SIDE>;
|
|
|
template class PawnPushGenerator<BLACK_SIDE>;
|
|
|
|
|
|
|
|
|
-std::string chessy::Move::asString(void) const
|
|
|
+std::string Move::asString(void) const
|
|
|
{
|
|
|
return origin.getName() + "-" + destination.getName();
|
|
|
}
|
|
|
|
|
|
|
|
|
+std::vector<Move> MoveGenerator::generatePossibleMoves(void) const
|
|
|
+{
|
|
|
+ const ChessGame& cg = game;
|
|
|
+ Bitboard whites = cg.getBoard().getWhites();
|
|
|
+ Bitboard blacks = cg.getBoard().getBlacks();
|
|
|
+ std::vector<Move> ret;
|
|
|
+ PawnPushGenerator<BLACK_SIDE> mg{ cg };
|
|
|
+ for (auto push : mg)
|
|
|
+ ret.push_back(push);
|
|
|
+ PositionSet knights = cg.getBoard().getBlackKnights();
|
|
|
+ for (auto knight : knights) {
|
|
|
+ for (auto pos : KnightMoveGenerator{ knight, blacks }) {
|
|
|
+ ret.push_back(Move{ knight, pos });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PositionSet bishops = cg.getBoard().getBlackBishops();
|
|
|
+ for (auto bishop : bishops) {
|
|
|
+ for (auto pos : PrimitiveBishopMoveGenerator{ bishop, whites, blacks }) {
|
|
|
+ ret.push_back(Move{ bishop, pos });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PositionSet rooks = cg.getBoard().getBlackRooks();
|
|
|
+ for (auto rook : rooks) {
|
|
|
+ for (auto pos : PrimitiveRookMoveGenerator{ rook, whites, blacks }) {
|
|
|
+ //cout << "rook: " << Move(rook, pos).asString() << endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PositionSet queens = cg.getBoard().getBlackQueens();
|
|
|
+ for (auto queen : queens) {
|
|
|
+ for (auto pos : PrimitiveQueenMoveGenerator{ queen, whites, blacks }) {
|
|
|
+ //cout << "queen: " << Move(queen, pos).asString() << endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Bitboard king = cg.getBoard().getBlackKings();
|
|
|
+ Index kingIndex = king.getLeastSignificantBit();
|
|
|
+ for (auto pos : KingMoveGenerator{ king, blacks }) {
|
|
|
+ //cout << "king: " << Move(kingIndex, pos).asString() << endl;
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
template<int side>
|
|
|
typename PawnPushGenerator<side>::MoveIterator PawnPushGenerator<side>::begin(void) const
|
|
|
{
|