MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / makeMove

Method makeMove

src/gamesbyexample/sudoku.py:54–68  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 4

sudoku.pyFile · 0.80
test_makeMoveFunction · 0.80
test_makeMoveFunction · 0.80
test_makeMoveFunction · 0.80

Calls

no outgoing calls

Tested by 3

test_makeMoveFunction · 0.64
test_makeMoveFunction · 0.64
test_makeMoveFunction · 0.64