From 9025383477acf5f9a6360877c502232eaec24e02 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Mon, 7 Mar 2022 11:30:55 +0100 Subject: Add WasEnPassant() method for convenience --- src/ChessArbiter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ChessArbiter.cpp') diff --git a/src/ChessArbiter.cpp b/src/ChessArbiter.cpp index 537c1a7..db1830c 100644 --- a/src/ChessArbiter.cpp +++ b/src/ChessArbiter.cpp @@ -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 moves = board.ListPossibleMoves(by); for (std::string &m : moves) { -- cgit v1.2.3