Simplify chess board rendering - plain text that works over SSH

- Remove complex Rich styling from board (caused rendering issues)
- Use simple ASCII box drawing (+---+) instead of Unicode box chars
- Use dots for dark squares, spaces for light
- Plain text status display
- Much more reliable over SSH terminals
This commit is contained in:
Greg Hendrickson
2026-01-27 18:53:54 +00:00
parent e3915f1b33
commit ed484e27a2
2 changed files with 52 additions and 76 deletions

View File

@@ -92,36 +92,34 @@ def test_game_status_render():
def test_chess_board_render():
"""Test that chess board renders without errors."""
output = StringIO()
console = Console(file=output, width=80, height=24, force_terminal=True, color_system="truecolor")
PIECES = {
'K': '', 'Q': '', 'R': '', 'B': '', 'N': '', 'P': '',
'k': '', 'q': '', 'r': '', 'b': '', 'n': '', 'p': '',
}
# Render a simple board section
console.print(" a b c d e f g h")
console.print(" ┌───┬───┬───┬───┬───┬───┬───┬───┐")
# Render one rank with colored squares
row = "8 │"
for file in range(8):
is_light = (7 + file) % 2 == 1
if is_light:
bg = "on #769656"
else:
bg = "on #4a7c3f"
# Starting position pieces
pieces_row = ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r']
char = PIECES.get(pieces_row[file], ' ')
row += f"[#1a1a1a bold {bg}] {char} [/]│"
# Simplified board rendering (plain text)
lines = []
lines.append(" a b c d e f g h")
lines.append(" +---+---+---+---+---+---+---+---+")
# Render rank 8 with pieces
pieces_row = ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r']
row = " 8 |"
for file, piece_char in enumerate(pieces_row):
char = PIECES.get(piece_char, '?')
row += f" {char} |"
row += " 8"
console.print(row)
lines.append(row)
lines.append(" +---+---+---+---+---+---+---+---+")
for line in lines:
output.write(line + "\n")
rendered = output.getvalue()
assert "a b c" in rendered
assert "" in rendered # Black rook
assert "+---+" in rendered
def test_narrow_terminal_render():