alpaca/alpacka/agents/stochastic_mcts.py
def _choose_action(self, node, visited):
        """Chooses the action to take in a given node based on child qualities.

        If avoid_loops is turned on, tries to avoid nodes visited on the path
        from the root.

        Args:
            node (TreeNode): Node to choose an action from.
            visited (set): Set of GraphNodes visited on the path from the root.

        Returns:
            Action to take.

        Raises:
            DeadEnd: If there's no child not visited before.
        """
        # TODO(koz4k): Distinguish exploratory/not.
        child_qualities = self._rate_children(node)
        child_qualities_and_actions = zip(
            child_qualities, range(len(child_qualities))
        )

        if self._avoid_loops:
            # Filter out nodes visited on the path from the root.
            child_graph_nodes = [child.graph_node for child in node.children]
            child_qualities_and_actions = [
                (quality, action)
                for (quality, action) in child_qualities_and_actions
                if child_graph_nodes[action] not in visited
            ]

        if not child_qualities_and_actions:
            # No unvisited child - dead end.
            raise DeadEnd

        (_, action) = max(child_qualities_and_actions)
        return action
Chooses the action to take in a given node based on child qualities.

        If avoid_loops is turned on, tries to avoid nodes visited on the path
        from the root.

        Args:
            node (TreeNode): Node to choose an action from.
            visited (set): Set of GraphNodes visited on the path from the root.

        Returns:
            Action to take.

        Raises:
            DeadEnd: If there's no child not visited before.
        
Chooses the action to take in a given node based on child qualities.
If avoid_loops is turned on, tries to avoid nodes visited on the path
from the root.
Chooses the action to take in a given node based on child qualities . If avoid_loops is turned on tries to avoid nodes visited on the path from the root .
def _choose_action(self, node, visited):
        child_qualities = self._rate_children(node)
        child_qualities_and_actions = zip(
            child_qualities, range(len(child_qualities))
        )
        if self._avoid_loops:
            child_graph_nodes = [child.graph_node for child in node.children]
            child_qualities_and_actions = [
                (quality, action)
                for (quality, action) in child_qualities_and_actions
                if child_graph_nodes[action] not in visited
            ]
        if not child_qualities_and_actions:
            raise DeadEnd
        (_, action) = max(child_qualities_and_actions)
        return action
def _choose_action ( self , node , visited ) : child_qualities = self . _rate_children ( node ) child_qualities_and_actions = zip ( child_qualities , range ( len ( child_qualities ) ) ) if self . _avoid_loops : child_graph_nodes = [ child . graph_node for child in node . children ] child_qualities_and_actions = [ ( quality , action ) for ( quality , action ) in child_qualities_and_actions if child_graph_nodes [ action ] not in visited ] if not child_qualities_and_actions : raise DeadEnd ( _ , action ) = max ( child_qualities_and_actions ) return action
Chooses the action to take in a given node based on child qualities.
Chooses the action to take in a given node based on child qualities .
"""Chooses the action to take in a given node based on child qualities.

        If avoid_loops is turned on, tries to avoid nodes visited on the path
        from the root.

        Args:
            node (TreeNode): Node to choose an action from.
            visited (set): Set of GraphNodes visited on the path from the root.

        Returns:
            Action to take.

        Raises:
            DeadEnd: If there's no child not visited before.
        """ # TODO(koz4k): Distinguish exploratory/not. # Filter out nodes visited on the path from the root. # No unvisited child - dead end.
Action to take.
Action to take .
If there's no child not visited before.
If there ' s no child not visited before .
DeadEnd
self
node
Node to choose an action from.
Node to choose an action from .
visited
Set of GraphNodes visited on the path from the root.
Set of GraphNodes visited on the path from the root .