alpaca/alpacka/agents/stochastic_mcts.py
def act(self, observation):
        """Runs n_passes MCTS passes and chooses the best action."""
        assert self._model is not None, (
            'MCTSAgent works only in model-based mode.'
        )
        self._root_state = self._model.clone_state()
        for _ in range(self.n_passes):
            yield from self._run_pass(self._root, observation)

        # Add the root to visited nodes after running the MCTS passes to ensure
        # it has a graph node assigned.
        self._real_visited.add(self._root.graph_node)

        try:
            # Avoid the nodes already visited on the path in the real
            # environment when choosing an action.
            action = self._choose_action(self._root, self._real_visited)
        except DeadEnd:
            action = random.randrange(len(self._root.children))
        self._root = self._root.children[action]
        return (action, {})
Runs n_passes MCTS passes and chooses the best action.
Runs n_passes MCTS passes and chooses the best action.
Runs n_passes MCTS passes and chooses the best action .
def act(self, observation):
        assert self._model is not None, (
            'MCTSAgent works only in model-based mode.'
        )
        self._root_state = self._model.clone_state()
        for _ in range(self.n_passes):
            yield from self._run_pass(self._root, observation)
        self._real_visited.add(self._root.graph_node)
        try:
            action = self._choose_action(self._root, self._real_visited)
        except DeadEnd:
            action = random.randrange(len(self._root.children))
        self._root = self._root.children[action]
        return (action, {})
def act ( self , observation ) : assert self . _model is not None , ( 'MCTSAgent works only in model-based mode.' ) self . _root_state = self . _model . clone_state ( ) for _ in range ( self . n_passes ) : yield from self . _run_pass ( self . _root , observation ) self . _real_visited . add ( self . _root . graph_node ) try : action = self . _choose_action ( self . _root , self . _real_visited ) except DeadEnd : action = random . randrange ( len ( self . _root . children ) ) self . _root = self . _root . children [ action ] return ( action , { } )
Runs n_passes MCTS passes and chooses the best action.
Runs n_passes MCTS passes and chooses the best action .
"""Runs n_passes MCTS passes and chooses the best action.""" # Add the root to visited nodes after running the MCTS passes to ensure # it has a graph node assigned. # Avoid the nodes already visited on the path in the real # environment when choosing an action.
self
observation