Пример #1
0
 def expand(self, leaf_state: TichuState) -> None:
     leaf_nid = self._graph_node_id(leaf_state)
     for action in leaf_state.possible_actions_gen():
         to_nid = self._graph_node_id(state=leaf_state.next_state(action))
         self.add_child_node(from_nid=leaf_nid,
                             to_nid=to_nid,
                             action=action)
Пример #2
0
    def _expand_tree(self, leaf_state: TichuState) -> None:
        """
        Expand all possible actions from the leaf_state
        
        :param history: The StateActionHistory up to the leaf_state. leaf_state not included. Following should hold: history.last_state.next_state(history.last_action) == leaf_state
        :param leaf_state: 
        :return: None
        """

        # logging.debug('expanding tree')
        leaf_infostate = TichuState.from_tichustate(leaf_state)

        for action in leaf_state.possible_actions_gen():
            to_infoset = TichuState.from_tichustate(
                leaf_state.next_state(action))
            self._add_new_node_if_not_yet_added(infoset=to_infoset)
            self._add_new_edge(from_infoset=leaf_infostate,
                               to_infoset=to_infoset,
                               action=action)