48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#ifndef CHESS_ENGINE_MOVE_HPP
|
|
#define CHESS_ENGINE_MOVE_HPP
|
|
|
|
#include "Square.hpp"
|
|
#include "Piece.hpp"
|
|
|
|
#include <iosfwd>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <limits>
|
|
|
|
class Move {
|
|
public:
|
|
|
|
using Optional = std::optional<Move>;
|
|
|
|
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);
|
|
|
|
Square from() const;
|
|
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::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
|
|
|
|
#endif
|