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

Function getNewBoard

src/gamesbyexample/sonar.py:17–28  ·  view source on GitHub ↗

Returns a dictionary representing the board. The keys are (x, y) tuples and the values are '~' and '.' strings to represent waves.

()

Source from the content-addressed store, hash-verified

15BOARD_HEIGHT = 15
16
17def getNewBoard():
18 """Returns a dictionary representing the board. The keys are (x, y)
19 tuples and the values are '~' and '.' strings to represent waves."""
20 board = {}
21 for x in range(BOARD_WIDTH):
22 for y in range(BOARD_HEIGHT):
23 # Add wave characters to the board:
24 if random.randint(0, 1) == 0:
25 board[(x, y)] = '~'
26 else:
27 board[(x, y)] = '.'
28 return board
29
30def displayBoard(board):
31 """Displays the board on the screen."""

Callers 1

sonar.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected