MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / displayBoard

Function displayBoard

src/gamesbyexample/checkers.py:68–100  ·  view source on GitHub ↗

Display the board data structure on the screen.

(board)

Source from the content-addressed store, hash-verified

66
67
68def displayBoard(board):
69 """Display the board data structure on the screen."""
70 # Contains all the characters to display in the board template.
71 spaces = []
72 for row in range(1, 9):
73 if row % 2 == 0:
74 for column in EVEN_CHECKER_COLUMNS:
75 spaces.append(board[column + str(row)])
76 else:
77 for column in ODD_CHECKER_COLUMNS:
78 spaces.append(board[column + str(row)])
79
80 # Display the board template with checkers/empty spaces:
81 print("""
82 A B C D E F G H
83 +---+---+---+---+---+---+---+---+
84 1 | | {} | | {} | | {} | | {} | 1
85 +---+---+---+---+---+---+---+---+
86 2 | {} | | {} | | {} | | {} | | 2
87 +---+---+---+---+---+---+---+---+
88 3 | | {} | | {} | | {} | | {} | 3
89 +---+---+---+---+---+---+---+---+
90 4 | {} | | {} | | {} | | {} | | 4
91 +---+---+---+---+---+---+---+---+
92 5 | | {} | | {} | | {} | | {} | 5
93 +---+---+---+---+---+---+---+---+
94 6 | {} | | {} | | {} | | {} | | 6
95 +---+---+---+---+---+---+---+---+
96 7 | | {} | | {} | | {} | | {} | 7
97 +---+---+---+---+---+---+---+---+
98 8 | {} | | {} | | {} | | {} | | 8
99 +---+---+---+---+---+---+---+---+
100 A B C D E F G H""".format(*spaces))
101
102
103def prevCol(column):

Callers 2

mainFunction · 0.70
makeMoveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected