我正在用 C#/Unity 開發一個國際象棋引擎,并希望以一種不錯的格式列印棋盤。最好我想用一些 Unicode 塊列印,但它們最終會使板子不均勻,見下圖:

正常數字似乎也是如此,因為每一行的開始都略微偏離,例如,第 1 行的開始位置比其他行更靠左。
為什么我的 Debug.Log/prints 會這樣結束,如何列印它們以使每個字符占用相同的空間?
編輯:這是我用來除錯的代碼。如果有幫助,請記錄板:
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);
}
uj5u.com熱心網友回復:
您正在尋找的不是“unicode”而是
(因為我不知道BitOperations你使用的是什么實作,所以我不得不花點心思)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/424493.html
