Skip to content
Snippets Groups Projects
Commit 680571d0 authored by Dipam Chakraborty's avatar Dipam Chakraborty
Browse files

Merge branch 'eric/agents' into 'master'

Move agents.

See merge request dipam/neurips-2021-nethack-challenge!2
parents 4d3405f5 4c718543
No related branches found
No related tags found
No related merge requests found
...@@ -3,19 +3,11 @@ import numpy as np ...@@ -3,19 +3,11 @@ import numpy as np
from agents.batched_agent import BatchedAgent from agents.batched_agent import BatchedAgent
class RandomAgent(BatchedAgent): class RandomAgent(BatchedAgent):
"""This random agent just selects an action from the action space."""
def __init__(self, num_envs, num_actions): def __init__(self, num_envs, num_actions):
super().__init__(num_envs, num_actions) super().__init__(num_envs, num_actions)
self.seeded_state = np.random.RandomState(42) self.seeded_state = np.random.RandomState(42)
def preprocess_observations(self, observations, rewards, dones, infos):
return observations, rewards, dones, infos
def postprocess_actions(self, actions):
return actions
def batched_step(self, observations, rewards, dones, infos): def batched_step(self, observations, rewards, dones, infos):
rets = self.preprocess_observations(observations, rewards, dones, infos)
observations, rewards, dones, infos = rets
actions = self.seeded_state.randint(self.num_actions, size=self.num_envs) actions = self.seeded_state.randint(self.num_actions, size=self.num_envs)
actions = self.postprocess_actions(actions)
return actions return actions
\ No newline at end of file
File moved
from agents.random_batched_agent import RandomAgent from agents.random_agent import RandomAgent
# from agents.torchbeast_batched_agent import TorchBeastAgent # from agents.torchbeast_batched_agent import TorchBeastAgent
# from agents.rllib_batched_agent import RLlibAgent # from agents.rllib_agent import RLlibAgent
from submission_wrappers import addtimelimitwrapper_fn from submission_wrappers import addtimelimitwrapper_fn
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment