Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. def make_move(self, move):
  2. """Apply move to current game.
  3.  
  4. Arguments:
  5. move: A pair (r, c) representing square self._state[0][r][c]
  6.  
  7. Assumptions:
  8. (r, c) are valid coordinates for self._state[0]. If they represent
  9. a valid move for current player, then the current player occupies
  10. that position and the opponent becomes the current player.
  11. Otherwise self._state is left unchanged.
  12.  
  13. Returns:
  14. New TicTacToe gamestate with move recorded on
  15. self._state[0] and current player replaced by opponent, if
  16. this is legal. Otherwise return None.
  17. """
  18.  
  19. #If given spot is empty, put current player in that spot
  20. #and return new gamestate
  21. if self._state([0][move[0]][move[1]]) == None:
  22.  
  23. state = list(copy.deepcopy(self._state[0]))
  24. state[move[0]][move[1]] = self.player()
  25. return TicTacToe((tuple(state), self.opponent()))
  26.  
  27. else:
  28. return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement