From 8dd8b6b622681323e0fb808ab687b00e6f72e7ed Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 26 Jul 2026 14:20:33 +0200 Subject: fixing print board --- src/board.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/board.cpp b/src/board.cpp index e8fa787..cbafcc6 100644 --- a/src/board.cpp +++ b/src/board.cpp @@ -35,41 +35,48 @@ Piece createPiece(pieceType type, bool color, bool moved) { }; void printBoard(board *b) { std::string line = " +-----------------+\n"; - std::string letter = " a b c d e f g h\n"; + std::string whiteLetters = " a b c d e f g h\n"; + std::string blackLetters = " h g f e d c b a\n"; - std::cout << letter; + std::cout << (b->turn ? whiteLetters : blackLetters); std::cout << line; if (b->turn) { for (int rank = 0; rank < 8; rank++) { std::printf("%d |", 8 - rank); + for (int file = 0; file < 8; file++) { Piece piece = b->pieces[rank * 8 + file]; char symbol = toChar(piece.type); - if (piece.color == false) { + + if (!piece.color) symbol = std::tolower(static_cast(symbol)); - } + std::printf(" %c", symbol); } + std::printf(" | %d\n", 8 - rank); } } else { for (int rank = 7; rank >= 0; rank--) { std::printf("%d |", 8 - rank); + for (int file = 7; file >= 0; file--) { Piece piece = b->pieces[rank * 8 + file]; char symbol = toChar(piece.type); - if (piece.color == false) { + + if (!piece.color) symbol = std::tolower(static_cast(symbol)); - } + std::printf(" %c", symbol); } + std::printf(" | %d\n", 8 - rank); } } std::cout << line; - std::cout << letter; + std::cout << (b->turn ? whiteLetters : blackLetters); std::println(); std::println("Turn: {}", b->turn ? "White" : "Black"); -- cgit v1.2.3