alpaca/alpacka/agents/shooting.py
def act(self, observation):
        """Runs n_rollouts simulations and chooses the best action."""
        assert self._model is not None, (
            'Reset ShootingAgent first.'
        )
        del observation

        # TODO(pj): Request network_fn and params here with yield.
        network_fn = functools.partial(networks.DummyNetwork, input_shape=None)
        params = None

        # Lazy initialize batch stepper
        if self._batch_stepper is None:
            self._batch_stepper = self._batch_stepper_class(
                env_class=type(self._model),
                agent_class=self._agent_class,
                network_fn=network_fn,
                n_envs=self._n_envs,
            )

        root_state = self._model.clone_state()

        # TODO(pj): Move it to BatchStepper. You should be able to query
        # BatchStepper for a given number of episodes (by default n_envs).
        global_n_rollouts = math.ceil(self._n_rollouts / self._n_envs)
        episodes = []
        for _ in range(global_n_rollouts):
            episodes.extend(self._batch_stepper.run_episode_batch(
                params,
                init_state=root_state,
                time_limit=self._rollout_time_limit,
            ))

        # Aggregate episodes into scores.
        action_scores = self._aggregate_fn(self._action_space.n, episodes)

        # Choose greedy action.
        action = np.argmax(action_scores)
        return action, {}
Runs n_rollouts simulations and chooses the best action.
Runs n_rollouts simulations and chooses the best action.
Runs n_rollouts simulations and chooses the best action .
def act(self, observation):
        assert self._model is not None, (
            'Reset ShootingAgent first.'
        )
        del observation
        network_fn = functools.partial(networks.DummyNetwork, input_shape=None)
        params = None
        if self._batch_stepper is None:
            self._batch_stepper = self._batch_stepper_class(
                env_class=type(self._model),
                agent_class=self._agent_class,
                network_fn=network_fn,
                n_envs=self._n_envs,
            )
        root_state = self._model.clone_state()
        global_n_rollouts = math.ceil(self._n_rollouts / self._n_envs)
        episodes = []
        for _ in range(global_n_rollouts):
            episodes.extend(self._batch_stepper.run_episode_batch(
                params,
                init_state=root_state,
                time_limit=self._rollout_time_limit,
            ))
        action_scores = self._aggregate_fn(self._action_space.n, episodes)
        action = np.argmax(action_scores)
        return action, {}
def act ( self , observation ) : assert self . _model is not None , ( 'Reset ShootingAgent first.' ) del observation network_fn = functools . partial ( networks . DummyNetwork , input_shape = None ) params = None if self . _batch_stepper is None : self . _batch_stepper = self . _batch_stepper_class ( env_class = type ( self . _model ) , agent_class = self . _agent_class , network_fn = network_fn , n_envs = self . _n_envs , ) root_state = self . _model . clone_state ( ) global_n_rollouts = math . ceil ( self . _n_rollouts / self . _n_envs ) episodes = [ ] for _ in range ( global_n_rollouts ) : episodes . extend ( self . _batch_stepper . run_episode_batch ( params , init_state = root_state , time_limit = self . _rollout_time_limit , ) ) action_scores = self . _aggregate_fn ( self . _action_space . n , episodes ) action = np . argmax ( action_scores ) return action , { }
Runs n_rollouts simulations and chooses the best action.
Runs n_rollouts simulations and chooses the best action .
"""Runs n_rollouts simulations and chooses the best action.""" # TODO(pj): Request network_fn and params here with yield. # Lazy initialize batch stepper # TODO(pj): Move it to BatchStepper. You should be able to query # BatchStepper for a given number of episodes (by default n_envs). # Aggregate episodes into scores. # Choose greedy action.
self
observation