I am developing a chess engine in C#/Unity and want to print the board on a nice format. Preferably I want to print with some Unicode pieces but they end up making the board uneven, see image below:
The same seems to go for normal numbers since each row starts slightly off one another, row 1 starts more left than the others for example.
Why does my Debug.Log/prints end up like this, and how can I print them so that each character takes up the same amount of space?
EDIT: Here is the code I use to Debug.Log the board if that helps:
public static void PrintBitboard(ulong bitboard)
{
string zero = " 0 ";
string one = " 1 ";
string printString = "";
// Loop through all squares and print a 1 if piece and 0 if not a piece on the square
for (int row = 0; row < 8; row )
{
// Add numbering on the left side
printString = (8 - row) " ";
for (int col = 0; col < 8; col )
{
int currentSquare = row * 8 col;
printString = BitOperations.GetBit(bitboard, currentSquare) != 0 ? one : zero;
}
// Change to new row
printString = "\n";
}
// Print bottom letters
printString = "\n" " a b c d e f g h";
// Send message to the console
Debug.Log(printString);
}
CodePudding user response:
What you are looking for is not "unicode" but
(in both I had to tricks a bit since I don't know what BitOperations
implementation you are using)