2025-02-02 18:17:37 +01:00
|
|
|
#pragma once
|
|
|
|
|
2025-02-02 17:13:55 +01:00
|
|
|
#include "castle_side.hpp"
|
2025-02-03 19:09:21 +01:00
|
|
|
#include "coords.hpp"
|
2025-02-03 19:09:13 +01:00
|
|
|
#include "pieces/piece.hpp"
|
2025-02-02 17:13:55 +01:00
|
|
|
|
2025-02-02 16:49:24 +01:00
|
|
|
#include <cstdint>
|
2025-02-04 21:51:14 +01:00
|
|
|
#include <sstream>
|
2025-02-02 16:49:24 +01:00
|
|
|
|
|
|
|
struct Move {
|
2025-02-02 18:17:37 +01:00
|
|
|
int8_t source_square;
|
2025-02-02 16:49:24 +01:00
|
|
|
int8_t target_square;
|
2025-02-02 17:13:55 +01:00
|
|
|
|
|
|
|
bool is_capturing = false;
|
2025-02-02 21:28:31 +01:00
|
|
|
CastleSide castle_side = CastleSide::NeitherSide;
|
2025-02-02 18:17:37 +01:00
|
|
|
bool en_passant = false;
|
2025-02-03 19:09:13 +01:00
|
|
|
int8_t promoting_to = Piece::None;
|
2025-02-04 21:51:14 +01:00
|
|
|
|
|
|
|
std::string to_string() const {
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << Coords::from_index(source_square)
|
|
|
|
<< Coords::from_index(target_square);
|
|
|
|
if (promoting_to != Piece::None) {
|
|
|
|
switch (promoting_to & 0b00111) {
|
|
|
|
case Queen:
|
|
|
|
ss << 'q';
|
|
|
|
break;
|
|
|
|
case Bishop:
|
|
|
|
ss << 'b';
|
|
|
|
break;
|
|
|
|
case Knigt:
|
|
|
|
ss << 'n';
|
|
|
|
break;
|
|
|
|
case Rook:
|
|
|
|
ss << 'r';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ss.str();
|
|
|
|
}
|
2025-02-02 16:49:24 +01:00
|
|
|
};
|
2025-02-03 19:09:21 +01:00
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, const Move& m) {
|
2025-02-04 21:51:14 +01:00
|
|
|
os << m.to_string();
|
2025-02-03 19:09:21 +01:00
|
|
|
return os;
|
|
|
|
}
|