made move str better (includes promotion)
This commit is contained in:
parent
609d5f8c98
commit
151a50fba9
@ -5,6 +5,7 @@
|
|||||||
#include "pieces/piece.hpp"
|
#include "pieces/piece.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
struct Move {
|
struct Move {
|
||||||
int8_t source_square;
|
int8_t source_square;
|
||||||
@ -14,10 +15,34 @@ struct Move {
|
|||||||
CastleSide castle_side = CastleSide::NeitherSide;
|
CastleSide castle_side = CastleSide::NeitherSide;
|
||||||
bool en_passant = false;
|
bool en_passant = false;
|
||||||
int8_t promoting_to = Piece::None;
|
int8_t promoting_to = Piece::None;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream& os, const Move& m) {
|
inline std::ostream& operator<<(std::ostream& os, const Move& m) {
|
||||||
os << Coords::from_index(m.source_square)
|
os << m.to_string();
|
||||||
<< Coords::from_index(m.target_square);
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user