From 0525bd565e4794b0444ce913e83fc43da57c5fa1 Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Fri, 7 Feb 2025 00:29:39 +0100 Subject: [PATCH] minor fixes --- cpp/src/model/board/board.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cpp/src/model/board/board.cpp b/cpp/src/model/board/board.cpp index 97c2b10..b537825 100644 --- a/cpp/src/model/board/board.cpp +++ b/cpp/src/model/board/board.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include Board Board::setup_fen_position(std::string fen) { @@ -112,7 +113,7 @@ std::string Board::to_fen() const { for (int rank = 7; rank >= 0; rank--) { int empty_cell_counter = 0; for (int file = 0; file < 8; file++) { - if (squares[rank * 8 + file] == Piece::None) { + if (piece_at({file, rank}) == Piece::None) { empty_cell_counter++; continue; } @@ -302,9 +303,11 @@ int8_t Board::get_king_of(int8_t colour) const { for (int i = 0; i < 64; i++) if (squares[i] == (colour | Piece::King)) return i; - throw std::domain_error( - "Apparently there no kings of the such color in this board" - ); + std::stringstream ss; + ss << "Apparently there no kings of the such color in this board: " + << std::endl; + ss << to_fen(); + throw std::domain_error(ss.str()); } bool Board::is_check_for(int8_t colour) const {