def successors(self, state):
     possible_actions = SeegaRules.get_player_actions(
         state, self.color.value)
     for action in possible_actions:
         next_state, done = SeegaRules.make_move(deepcopy(state), action,
                                                 self.color.value)
         yield action, next_state
Beispiel #2
0
 def successors(self, state):
     possible_actions = SeegaRules.get_player_actions(
         state, self.color.value)
     print("POSSIBLE MOVES :")
     for i, action in enumerate(possible_actions):
         print(i, action)
     move = int(input("SELECTED MOVE ?"))
     next_state, done = SeegaRules.make_move(deepcopy(state),
                                             possible_actions[move],
                                             self.color.value)
     print(f"SELECTION : {move} - {possible_actions[move]}\n{next_state}")
     yield possible_actions[move], next_state
    def successors(self, state: SeegaState):
        """
        The successors function must return (or yield) a list of
        pairs (a, s) in which a is the action played to reach the state s.
        """
        next_player = state.get_next_player()
        possible_actions = get_possible_actions(state, next_player)
        succ = []
        for action in possible_actions:
            next_state, done = SeegaRules.make_move(deepcopy(state), action,
                                                    next_player)
            succ.append((action, next_state))

        return succ
Beispiel #4
0
    def successors(self, state: SeegaState):
        """
        The successors function must return (or yield) a list of
        pairs (a, s) in which a is the action played to reach the state s.
        """
        if state in self.cache_successors:
            self.cache_successors['hits'] += 1
            return self.cache_successors[state]

        next_player = state.get_next_player()
        possible_actions = SeegaRules.get_player_actions(state, next_player)
        succ = []
        for action in possible_actions:
            next_state, done = SeegaRules.make_move(deepcopy(state), action,
                                                    next_player)
            succ.append((action, next_state))

        self.cache_successors['misses'] += 1
        self.cache_successors[state] = succ
        return succ