Return True if the player occupies three of the four watering holes on this board.
(player, board)
| 331 | |
| 332 | |
| 333 | def isWinner(player, board): |
| 334 | """Return True if the player occupies three of the four watering |
| 335 | holes on this board.""" |
| 336 | squareClaims = 0 |
| 337 | roundClaims = 0 |
| 338 | for space in WATERING_HOLES: |
| 339 | if board[space] in (SQUARE_MOUSE, SQUARE_LION, SQUARE_ELEPHANT): |
| 340 | squareClaims += 1 |
| 341 | elif board[space] in (ROUND_MOUSE, ROUND_LION, ROUND_ELEPHANT): |
| 342 | roundClaims += 1 |
| 343 | |
| 344 | if player == SQUARE_PLAYER and squareClaims >= 3: |
| 345 | return True |
| 346 | elif player == ROUND_PLAYER and roundClaims >= 3: |
| 347 | return True |
| 348 | else: |
| 349 | return False |
| 350 | |
| 351 | |
| 352 | # If the program is run (instead of imported), run the game: |