This commit is contained in:
2022-12-23 23:57:29 +01:00
parent 87adca7e66
commit cb0fcc4702
14 changed files with 208 additions and 52 deletions

View File

@@ -7,14 +7,17 @@
#include <iosfwd>
#include <optional>
#include <string>
#include <limits>
class Move {
public:
using Optional = std::optional<Move>;
Move(const Square &from, const Square &to,
const std::optional<PieceType> &promotion = std::nullopt);
explicit Move(const Square &from, const Square &to);
explicit Move(const Square &from, const Square &to,
const std::optional<PieceType> &promotion, unsigned score = 0);
explicit Move(const Square &from, const Square &to, unsigned score);
static Optional fromUci(const std::string &uci);
@@ -22,16 +25,23 @@ public:
Square to() const;
std::optional<PieceType> promotion() const;
friend bool operator<(const Move &lhs, const Move &rhs);
friend bool operator==(const Move &lhs, const Move &rhs);
private:
Square mFrom;
Square mTo;
std::optional<PieceType> mPromotion;
std::optional<PieceType> mPromotion = std::nullopt;
unsigned mScore = std::numeric_limits<unsigned>::max();
public:
unsigned int score() const;
void setScore(unsigned int mScore);
};
std::ostream &operator<<(std::ostream &os, const Move &move);
// Needed for std::map, std::set
bool operator<(const Move &lhs, const Move &rhs);
bool operator==(const Move &lhs, const Move &rhs);
#endif