Return a dictionary that represent the board. The keys are (x, y) integer tuples for positions and the values are one of the animal piece constants e.g. SQUARE_ELEPHANT or ROUND_LION
()
| 104 | |
| 105 | |
| 106 | def getNewBoard(): |
| 107 | """Return a dictionary that represent the board. The keys are (x, y) |
| 108 | integer tuples for positions and the values are one of the animal |
| 109 | piece constants e.g. SQUARE_ELEPHANT or ROUND_LION""" |
| 110 | # First, set the board to be completely empty: |
| 111 | board = {} # Keys are (x, y) int tuples, values are player pieces. |
| 112 | for x in range(BOARD_WIDTH): |
| 113 | for y in range(BOARD_HEIGHT): |
| 114 | board[(x, y)] = EMPTY_SPACE |
| 115 | |
| 116 | # Next, place the pieces in their starting positions: |
| 117 | board[(4, 0)] = board[(5, 0)] = SQUARE_ELEPHANT |
| 118 | board[(3, 1)] = board[(6, 1)] = SQUARE_LION |
| 119 | board[(4, 1)] = board[(5, 1)] = SQUARE_MOUSE |
| 120 | board[(4, 9)] = board[(5, 9)] = ROUND_ELEPHANT |
| 121 | board[(3, 8)] = board[(6, 8)] = ROUND_LION |
| 122 | board[(4, 8)] = board[(5, 8)] = ROUND_MOUSE |
| 123 | |
| 124 | return board |
| 125 | |
| 126 | |
| 127 | def displayBoard(board): |