Return True if the player's piece at (x, y) on the board can capture the piece forward and left. Otherwise return False.
(player, x, y, board)
| 252 | |
| 253 | |
| 254 | def pieceCanCaptureLeft(player, x, y, board): |
| 255 | """Return True if the player's piece at (x, y) on the board can |
| 256 | capture the piece forward and left. Otherwise return False.""" |
| 257 | # Can this piece capture an opponent's piece? |
| 258 | if player == X_PLAYER: # X's "forward" is the space below. |
| 259 | # Check diagonally forward and left: |
| 260 | if (x - 1, y + 1) in board and board[(x - 1, y + 1)] == O_PLAYER: |
| 261 | return True |
| 262 | elif player == O_PLAYER: # O's "forward" is the space above. |
| 263 | # Check diagonally forward and left: |
| 264 | if (x - 1, y - 1) in board and board[(x - 1, y - 1)] == X_PLAYER: |
| 265 | return True |
| 266 | return False # This piece cannot capture. |
| 267 | |
| 268 | |
| 269 | def pieceCanCaptureRight(player, x, y, board): |
no outgoing calls
no test coverage detected