Return True if the player has reached the opposite end of the board and won. Otherwise return False.
(player, board)
| 282 | |
| 283 | |
| 284 | def checkIfPlayerReachedEnd(player, board): |
| 285 | """Return True if the player has reached the opposite end of the |
| 286 | board and won. Otherwise return False.""" |
| 287 | if player == X_PLAYER: |
| 288 | # Check if X has any pieces on the bottom row: |
| 289 | for x in range(board['width']): |
| 290 | if board[(x, board['height'] - 1)] == X_PLAYER: |
| 291 | return True |
| 292 | return False |
| 293 | elif player == O_PLAYER: |
| 294 | # Check if O has any pieces on the top row: |
| 295 | for x in range(board['width']): |
| 296 | if board[(x, 0)] == O_PLAYER: |
| 297 | return True |
| 298 | return False |
| 299 | |
| 300 | |
| 301 | # If this program was run (instead of imported), run the game: |