Piece: expanding getLegalMoves for Queen/Knight/Bishop

This commit is contained in:
A.M. Rowsell 2025-08-30 18:46:18 -04:00
commit 6773da28fb
Signed by untrusted user who does not match committer: amr
GPG key ID: E0879EDBDB0CA7B1
4 changed files with 70 additions and 5 deletions

View file

@ -13,6 +13,7 @@
#include <memory>
#include <string>
#include <vector>
#include <iostream>
#include "Piece.hpp"
@ -32,6 +33,7 @@ public:
std::vector<std::vector<std::unique_ptr<Piece>>> boardGrid;
Board();
virtual ~Board();
void setupInitialPosition();
std::unique_ptr<Piece> &getPieceAt(Square square);
void movePiece(Square from, Square to);

View file

@ -8,7 +8,6 @@
#ifndef PIECE_HPP
#define PIECE_HPP
#pragma once
#include <cstdint>
#include <algorithm>
@ -115,6 +114,13 @@ class King : public Piece {
else
return false;
}
void setCastleQS(bool canCastle) {
canCastleQS = canCastle;
}
void setCastleKS(bool canCastle) {
canCastleKS = canCastle;
}
protected:
bool canCastleQS = true;
bool canCastleKS = true;
@ -179,6 +185,10 @@ class Pawn : public Piece {
pieceType = PAWN;
}
virtual std::vector<Move> getLegalMoves(const Square &from, Board &board) const override;
void promote(const Square &promotionSquare, Board &board, PieceType promoteTo);
protected:
bool vulnEnPassant = false;
bool firstMove = true;
};
#endif // PIECE_HPP