/* * This dumps a string that looks like: * * +---------------+ * 8|r . b . . r k .| * 7|. . . . n p p p| * 6|p . . . p . . .| * 5|. . q p P . . .| * 4|. . . . . . . .| * 3|. . N . . N . .| * 2|P P . . . P P P| * 1|. . R Q . R K .| * A B C D E F G H * * - or - * * +---------------+ * 8|♜ . ♝ . . ♜ ♚ .| * 7|. . . . ♞ ♟ ♟ ♟| * 6|♟ . . . ♟ . . .| * 5|. . ♛ ♟ ♙ . . .| * 4|. . . . . . . .| * 3|. . ♘ . . ♘ . .| * 2|♙ ♙ . . . ♙ ♙ ♙| * 1|. . ♖ ♕ . ♖ ♔ .| * A B C D E F G H * */ private static string BoardToStr(Position b, bool unicode = false) { StringBuilder sb = new StringBuilder(); sb.AppendLine(" +---------------+"); for (int rank = 7; rank >= 0; rank--) { sb.Append($" {rank + 1}|"); for (int file = 0; file < 8; file++) { var(color, pieceType) = b.GetPiece(Position.IxFromFileRank(file, rank)); char pieceDisplay = '.'; if (pieceType != PieceType.None) { if (unicode) { pieceDisplay = BoardParsing.UnicodePieceFromPieceTypeColor(pieceType, color); } else { pieceDisplay = BoardParsing.LetterFromPieceTypeColor(pieceType, color); } } sb.Append(pieceDisplay); if (file < 7) { sb.Append(" "); } } sb.AppendLine("|"); } sb.Append(" "); for (int file = 0; file < 8; file++) { sb.Append($"{(char)('A' + file)} "); } return(sb.ToString()); }
public static void Dump(Position position, bool unicode = false) { foreach (var color in new[] { Color.White, Color.Black }) { for (PieceType pieceType = 0; pieceType < PieceType.Count; pieceType++) { Dump($"{color} {pieceType}:"); Dump(position.GetPieceBitboard(color, pieceType)); } } Dump(); Dump(BoardToStr(position, unicode)); Dump(""); string enPassant = BoardParsing.SquareStrFromValue(position.EnPassant); string castling = BoardParsing.CastlingStrFromValue(position.CastlingRights); Dump($"Side to move: {position.SideToMove}; Move#: {position.FullMove}; Castling: {castling}; En Passant: {enPassant}; 50 move counter: {position.FiftyMoveCounter}"); Dump($"Zobrist hash: 0x{position.ZobristHash:X16}"); Dump(BoardParsing.FenStringFromBoard(position)); }
public static void Dump(Move move) { Dump(BoardParsing.NaiveSanStringFromMove(move)); }