mirror of
https://gitlab.com/manzerbredes/chessarbiter.git
synced 2025-05-23 07:37:40 +00:00
Add WasEnPassant() method for convenience
This commit is contained in:
parent
934b00f729
commit
9025383477
3 changed files with 15 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
|||
namespace chessarbiter {
|
||||
ChessArbiter::ChessArbiter()
|
||||
: wPawn(1), wRook(5), wKnight(3), wBishop(3), wQueen(9), wKing(0), SAN(""),
|
||||
capture(' ') {
|
||||
capture(' '), was_enpassant(false) {
|
||||
Setup("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ bool ChessArbiter::Play(std::string move) {
|
|||
INIT_BACKUP();
|
||||
SAN = "";
|
||||
capture = ' ';
|
||||
was_enpassant=false;
|
||||
|
||||
if (IsCapture) {
|
||||
capture = board.GetPieceAt(dst).piece;
|
||||
|
@ -120,6 +121,7 @@ bool ChessArbiter::Play(std::string move) {
|
|||
board.RemovePiece(dst[0] + std::string() + (char)(dst[1] - 1));
|
||||
capture = 'p';
|
||||
}
|
||||
was_enpassant=true;
|
||||
}
|
||||
newFen.halfmove = 0; // Pawn moves reset half moves
|
||||
}
|
||||
|
@ -173,6 +175,8 @@ bool ChessArbiter::Play(std::string move) {
|
|||
return (false);
|
||||
}
|
||||
|
||||
bool ChessArbiter::WasEnPassant() { return (was_enpassant); }
|
||||
|
||||
bool ChessArbiter::IsAttacked(std::string square, bool by) {
|
||||
std::vector<std::string> moves = board.ListPossibleMoves(by);
|
||||
for (std::string &m : moves) {
|
||||
|
|
|
@ -10,14 +10,16 @@
|
|||
if (positions.find(fen.board) != positions.end()) \
|
||||
positions_backup = positions[fen.board]; \
|
||||
std::string SAN_backup = SAN; \
|
||||
char capture_backup = capture;
|
||||
char capture_backup = capture; \
|
||||
bool was_enpassant_backup = was_enpassant;
|
||||
|
||||
#define RESTORE_BACKUP() \
|
||||
SetFEN(fen_backup); \
|
||||
if (positions_backup != 0) \
|
||||
positions[fen.board] = positions_backup; \
|
||||
SAN = SAN_backup; \
|
||||
capture = capture_backup;
|
||||
capture = capture_backup; \
|
||||
was_enpassant = was_enpassant_backup;
|
||||
|
||||
namespace chessarbiter {
|
||||
class ChessArbiter {
|
||||
|
@ -31,6 +33,7 @@ class ChessArbiter {
|
|||
void SetFEN(FEN);
|
||||
std::string SAN, SAN_last;
|
||||
char capture;
|
||||
bool was_enpassant;
|
||||
|
||||
public:
|
||||
ChessArbiter();
|
||||
|
@ -65,6 +68,7 @@ public:
|
|||
bool IsDrawByNoMoves();
|
||||
bool IsDrawByRepetitions();
|
||||
bool IsDraw();
|
||||
bool WasEnPassant();
|
||||
std::string ParseSAN(std::string SANMove);
|
||||
};
|
||||
} // namespace chessarbiter
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue