From b282a6e494327c70431ea30f6b07cd7a2fb7bd97 Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Sun, 18 Dec 2022 18:23:05 +0100 Subject: [PATCH] [Move] Initial implementation --- Move.cpp | 19 ++++++++----------- Move.hpp | 4 ++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Move.cpp b/Move.cpp index dbeecab..226cb3f 100644 --- a/Move.cpp +++ b/Move.cpp @@ -2,11 +2,8 @@ #include -Move::Move(const Square &from, const Square &to, - const std::optional &promotion) { - (void) from; - (void) to; - (void) promotion; +Move::Move(const Square &from, const Square &to, const std::optional &promotion) + : mFrom(from), mTo(to), mPromotion(promotion) { } Move::Optional Move::fromUci(const std::string &uci) { @@ -15,15 +12,15 @@ Move::Optional Move::fromUci(const std::string &uci) { } Square Move::from() const { - return Square::A1; + return mFrom; } Square Move::to() const { - return Square::A1; + return mTo; } std::optional Move::promotion() const { - return std::nullopt; + return mPromotion; } std::ostream &operator<<(std::ostream &os, const Move &move) { @@ -38,7 +35,7 @@ bool operator<(const Move &lhs, const Move &rhs) { } bool operator==(const Move &lhs, const Move &rhs) { - (void) lhs; - (void) rhs; - return false; + return lhs.from() == rhs.from() + && lhs.to() == rhs.to() + && lhs.promotion() == rhs.promotion(); } diff --git a/Move.hpp b/Move.hpp index 63ebf87..48346ad 100644 --- a/Move.hpp +++ b/Move.hpp @@ -22,6 +22,10 @@ public: Square to() const; std::optional promotion() const; +private: + const Square mFrom; + const Square mTo; + const std::optional mPromotion; }; std::ostream &operator<<(std::ostream &os, const Move &move);