summaryrefslogtreecommitdiff
path: root/src/Board.cpp
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-16 15:18:26 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-16 15:18:26 +0100
commit0584edb107467a294f17a50d063e667f22f4a47b (patch)
tree67e95c79a1fc71562dcf9d65e9f614614154ed74 /src/Board.cpp
parent94c2565647d84f31d5ccac0d88717aef29d4a9a1 (diff)
Enable to retreive SAN move
Diffstat (limited to 'src/Board.cpp')
-rw-r--r--src/Board.cpp14
1 files changed, 14 insertions, 0 deletions
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++) {