[Move] Initial implementation
This commit is contained in:
19
Move.cpp
19
Move.cpp
@@ -2,11 +2,8 @@
|
|||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
Move::Move(const Square &from, const Square &to,
|
Move::Move(const Square &from, const Square &to, const std::optional<PieceType> &promotion)
|
||||||
const std::optional<PieceType> &promotion) {
|
: mFrom(from), mTo(to), mPromotion(promotion) {
|
||||||
(void) from;
|
|
||||||
(void) to;
|
|
||||||
(void) promotion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Move::Optional Move::fromUci(const std::string &uci) {
|
Move::Optional Move::fromUci(const std::string &uci) {
|
||||||
@@ -15,15 +12,15 @@ Move::Optional Move::fromUci(const std::string &uci) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Square Move::from() const {
|
Square Move::from() const {
|
||||||
return Square::A1;
|
return mFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
Square Move::to() const {
|
Square Move::to() const {
|
||||||
return Square::A1;
|
return mTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<PieceType> Move::promotion() const {
|
std::optional<PieceType> Move::promotion() const {
|
||||||
return std::nullopt;
|
return mPromotion;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const Move &move) {
|
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) {
|
bool operator==(const Move &lhs, const Move &rhs) {
|
||||||
(void) lhs;
|
return lhs.from() == rhs.from()
|
||||||
(void) rhs;
|
&& lhs.to() == rhs.to()
|
||||||
return false;
|
&& lhs.promotion() == rhs.promotion();
|
||||||
}
|
}
|
||||||
|
4
Move.hpp
4
Move.hpp
@@ -22,6 +22,10 @@ public:
|
|||||||
Square to() const;
|
Square to() const;
|
||||||
std::optional<PieceType> promotion() const;
|
std::optional<PieceType> promotion() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Square mFrom;
|
||||||
|
const Square mTo;
|
||||||
|
const std::optional<PieceType> mPromotion;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const Move &move);
|
std::ostream &operator<<(std::ostream &os, const Move &move);
|
||||||
|
Reference in New Issue
Block a user