Returns a dictionary representing the board. The keys are (x, y) tuples and the values are '~' and '.' strings to represent waves.
()
| 15 | BOARD_HEIGHT = 15 |
| 16 | |
| 17 | def 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 | |
| 30 | def displayBoard(board): |
| 31 | """Displays the board on the screen.""" |