Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def make_move(self, move):
- """Apply move to current game.
- Arguments:
- move: A pair (r, c) representing square self._state[0][r][c]
- Assumptions:
- (r, c) are valid coordinates for self._state[0]. If they represent
- a valid move for current player, then the current player occupies
- that position and the opponent becomes the current player.
- Otherwise self._state is left unchanged.
- Returns:
- New TicTacToe gamestate with move recorded on
- self._state[0] and current player replaced by opponent, if
- this is legal. Otherwise return None.
- """
- #If given spot is empty, put current player in that spot
- #and return new gamestate
- if self._state([0][move[0]][move[1]]) == None:
- state = list(copy.deepcopy(self._state[0]))
- state[move[0]][move[1]] = self.player()
- return TicTacToe((tuple(state), self.opponent()))
- else:
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement