Place the number at the column (a letter from A to I) and row (an integer from 1 to 9) on the grid.
(self, column, row, number)
| 52 | y += 1 |
| 53 | |
| 54 | def makeMove(self, column, row, number): |
| 55 | """Place the number at the column (a letter from A to I) and row |
| 56 | (an integer from 1 to 9) on the grid.""" |
| 57 | x = 'ABCDEFGHI'.find(column) # Convert this to an integer. |
| 58 | y = int(row) - 1 |
| 59 | |
| 60 | # Check if the move is being made on a "given" number: |
| 61 | if self.originalSetup[y * GRID_LENGTH + x] != EMPTY_SPACE: |
| 62 | return False |
| 63 | |
| 64 | self.grid[(x, y)] = number # Place this number on the grid. |
| 65 | |
| 66 | # We need to store a separate copy of the dictionary object: |
| 67 | self.moves.append(copy.copy(self.grid)) |
| 68 | return True |
| 69 | |
| 70 | def undo(self): |
| 71 | """Set the current grid state to the previous state in the |
no outgoing calls