Return True if the peg can make the given move.
(board, space, direction)
| 85 | |
| 86 | |
| 87 | def canMoveInDirection(board, space, direction): |
| 88 | """Return True if the peg can make the given move.""" |
| 89 | nextSpace, secondNextSpace = getNeighboringSpaces(space, direction) |
| 90 | |
| 91 | # Check if the neighboring space exists: |
| 92 | if nextSpace in ALL_SPACES: |
| 93 | # Check if there is a peg in the neighboring space: |
| 94 | if board[nextSpace] == PEG: |
| 95 | # Check if the neighbor's neighboring space exists: |
| 96 | if secondNextSpace in ALL_SPACES: |
| 97 | # Check if there is an empty space there: |
| 98 | if board[secondNextSpace] == EMPTY: |
| 99 | return True |
| 100 | return False |
| 101 | |
| 102 | |
| 103 | def getMoveablePegs(board): |
no test coverage detected