stellar

Stellar - UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE

commit 853218b1217d154545e1844f4022147d1c6d22e7
parent 644090d7e796c3e13c7595700830ddcad8836754
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed, 20 Mar 2024 20:55:59 +0000

Tweak arena for consistent san and winner message

Diffstat:
Msrc/arena/game.cpp | 4++--
Msrc/arena/game.hpp | 1+
Msrc/arena/match.cpp | 2+-
3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/arena/game.cpp b/src/arena/game.cpp @@ -41,8 +41,9 @@ const std::string Game::to_san(const Board &board, const Move move) { std::string res; if (piece != PAWN) { - U64 potential = board.get_bitboard_square_land(move.target(), piece, board.get_side()); + res += piece::get_code(piece, WHITE); + U64 potential = board.get_bitboard_square_land(move.target(), piece, board.get_side()); if (bit::count(potential) > 1) { int file[9] = {0}, rank[9] = {0}; uint8_t square_i = 0; @@ -60,7 +61,6 @@ const std::string Game::to_san(const Board &board, const Move move) { res += crd; } - res += piece::get_code(piece, WHITE); if (target != Type::NO_TYPE) res += "x"; res += to_coordinates(move.target()); } else { diff --git a/src/arena/game.hpp b/src/arena/game.hpp @@ -26,6 +26,7 @@ class Game { [[nodiscard]] const bool is_win_white() const { return !draw && winner == WHITE; } [[nodiscard]] const bool is_win_black() const { return !draw && winner == BLACK; } [[nodiscard]] const bool is_draw() const { return draw; } + [[nodiscard]] const Color get_winner() const { return winner; } void set_terminate(const Terminate terminate) { this->terminate = terminate; } void set_winner(const Color winner) { this->winner = winner; } diff --git a/src/arena/match.cpp b/src/arena/match.cpp @@ -78,7 +78,7 @@ Game Match::play(Settings swhite, Settings sblack, const std::string &fen = Game } if (!game.is_draw()) { - logger::log(std::format("Match {}: winner is {}", id, to_string(turn))); + logger::log(std::format("Match {}: winner is {}", id, to_string(game.get_winner()))); } else { logger::log(std::format("Match {}: ended in a draw", id)); }