def successor(self, agent_index, action): """ Returns the the state that results when the given action is applied. (State, int, str) -> State """ # Check that successors exist if self.terminal: raise Exception('Can\'t generate a successor of a terminal state.') # Copy current state state = self.deepcopy() # Let agent's logic deal with its action's effects on the board if agent_index == 0: from game_rules import RedBirdRules RedBirdRules.apply_action(state, action) else: from game_rules import BlackBirdRules BlackBirdRules.apply_action(state, action) # Book keeping state._agent_moved = agent_index state.score += state.score_change return state
def successor(self, agent_index, action): """ Returns the the state that results when the given action is applied. (State, int, str) -> State """ # Check that successors exist if self.terminal: raise Exception('Can\'t generate a successor of a terminal state.') # Copy current state state = self.deepcopy() # Let agent's logic deal with its action's effects on the board if agent_index == 0: from game_rules import RedBirdRules RedBirdRules.apply_action(state, action) else: from game_rules import BlackBirdRules BlackBirdRules.apply_action(state, action) # Book keeping state._agent_moved = agent_index state.score += state.score_change return state