Skip to content

Commit

Permalink
feat: show fen position when encountering an illegal pv move (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
Disservin committed Jun 23, 2024
1 parent e5ee559 commit 45a67f9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/src/matchmaking/match/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,27 @@ bool Match::isUciMove(const std::string& move) noexcept {

void Match::verifyPvLines(const Player& us) {
const static auto verifyPv = [](Board board, const std::vector<std::string>& tokens, std::string_view info) {
auto it_start = std::find(tokens.begin(), tokens.end(), "pv") + 1;
auto it_end = std::find_if(it_start, tokens.end(), [](const auto& token) { return !isUciMove(token); });
const auto fen = board.getFen();
auto it_start = std::find(tokens.begin(), tokens.end(), "pv") + 1;
auto it_end = std::find_if(it_start, tokens.end(), [](const auto& token) { return !isUciMove(token); });

Movelist moves;
std::string uci_moves;

while (it_start != it_end) {
movegen::legalmoves(moves, board);

if (std::find(moves.begin(), moves.end(), uci::uciToMove(board, *it_start)) == moves.end()) {
Logger::warn<true>("Warning; Illegal pv move {} pv: {}", *it_start, info);
auto fmt = fmt::format("Warning; Illegal pv move {} pv: {}", *it_start, info);
auto fmt2 = fmt::format("From; position fen {} moves{}", fen, uci_moves);
Logger::warn<true>(fmt + "\n" + fmt2);

break;
}

uci_moves += " " + *it_start;
board.makeMove(uci::uciToMove(board, *it_start));

it_start++;
}
};
Expand Down

0 comments on commit 45a67f9

Please sign in to comment.