From 0584edb107467a294f17a50d063e667f22f4a47b Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Wed, 16 Feb 2022 15:18:26 +0100 Subject: Enable to retreive SAN move --- src/Board.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/Board.cpp') diff --git a/src/Board.cpp b/src/Board.cpp index 6546354..2c7c3f0 100644 --- a/src/Board.cpp +++ b/src/Board.cpp @@ -83,6 +83,20 @@ void Board::Move(std::string move) { } } +bool Board::IsPieceMoveUnique(char piece, std::string move_dst) { + bool isBlack = std::islower(piece); + unsigned char count = 0; + for (std::string &move : ListPossibleMoves(isBlack)) { + std::string src = move.substr(0, 2); + std::string dst = move.substr(2, 2); + Piece p = GetPieceAt(src); // Never fails since it is legal + if (p.piece == piece && move_dst == dst) { + count++; + } + } + return (count <= 1); +} + std::string Board::Serialize() { std::string s; for (short i = 0; i < 8; i++) { -- cgit v1.2.3