diff --git a/Board.cpp b/Board.cpp index 8320e39..6aa3325 100644 --- a/Board.cpp +++ b/Board.cpp @@ -71,6 +71,25 @@ void Board::pseudoLegalMovesFrom(const Square &from, } std::ostream &operator<<(std::ostream &os, const Board &board) { - (void) board; + // For debugging only, performance isn't important + for (int i = 63; i >= 0; i--) { + // Get the piece for this index. Assume it exists. + auto piece = board.piece(Square::fromIndex(i).value()); + + // Print piece, otherwise '.'; + if (piece.has_value()) { + os << piece.value(); + } else { + os << '.'; + } + + // If a file is done, output newline + if (i % 8 == 0) { + os << '\n'; + } else { + os << ' '; + } + } + return os; }