From a7f9e689391cfc0c270d012d2a65d1238abd1c4b Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Mon, 8 Dec 2025 15:03:35 +0100 Subject: [PATCH] make the board show function look a lot better --- blokus.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/blokus.py b/blokus.py index b61cd6e..975c252 100755 --- a/blokus.py +++ b/blokus.py @@ -34,27 +34,34 @@ def print_game_state(game_state: tuple[game.Board, list[int], list[int]]): (board, p1tiles, p2tiles) = game_state barr = [] - for i in range(BOARD_SIZE): - barr.append([]) - for j in range(BOARD_SIZE): - barr[i].append(board[(j, i)]) + for y in range(BOARD_SIZE): + row = [] + for x in range(BOARD_SIZE): + row.append(board[(x, y)]) + barr.append(row) - print(f" {'-' * BOARD_SIZE} ") + print(f" {'--' * BOARD_SIZE} ") for row in barr: print( f"|{ ''.join( [ - ' ' if x == 0 else 'X' if x == 1 else 'O' if x == 2 else 'S' + ' ' + if x == 0 + else '\033[93m██\033[00m' + if x == 1 + else '\033[94m██\033[00m' + if x == 2 + else '██' for x in row ] ) }|" ) - print(f" {'-' * BOARD_SIZE} ") + print(f" {'--' * BOARD_SIZE} ") - print(f"Player 1 tiles left: {p1tiles}") - print(f"Player 2 tiles left: {p2tiles}") + print(f"\033[93mPlayer 1\033[00m tiles left: {p1tiles}") + print(f"\033[94mPlayer 2\033[00m tiles left: {p2tiles}") def plot_losses(loss_history, out_path="loss_curve.png"):