(x, y)
| 165 | |
| 166 | |
| 167 | def getRandomNeighbor(x, y): |
| 168 | while True: |
| 169 | direction = random.choice((NORTH, SOUTH, EAST, WEST)) |
| 170 | if direction == NORTH and y != 0: |
| 171 | return (x, y - 1) |
| 172 | elif direction == SOUTH and y != HEIGHT - 1: |
| 173 | return (x, y + 1) |
| 174 | elif direction == EAST and x != WIDTH - 1: |
| 175 | return (x + 1, y) |
| 176 | elif direction == WEST and x != 0: |
| 177 | return (x - 1, y) |
| 178 | |
| 179 | |
| 180 | # If this program was run (instead of imported), run the game: |