From eed51f36c38b6af4d55cf0c803f7fc05fc7aae61 Mon Sep 17 00:00:00 2001 From: Dipam Chakraborty <dipam@aicrowd.com> Date: Sun, 6 Jun 2021 12:55:24 +0000 Subject: [PATCH] Revert "Merge branch 'eric/agents' into 'master'" This reverts merge request !2 --- agents/{random_agent.py => random_batched_agent.py} | 10 +++++++++- agents/{rllib_agent.py => rllib_batched_agent.py} | 0 submission_config.py | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) rename agents/{random_agent.py => random_batched_agent.py} (52%) rename agents/{rllib_agent.py => rllib_batched_agent.py} (100%) diff --git a/agents/random_agent.py b/agents/random_batched_agent.py similarity index 52% rename from agents/random_agent.py rename to agents/random_batched_agent.py index 1ed471c..ae426a5 100644 --- a/agents/random_agent.py +++ b/agents/random_batched_agent.py @@ -3,11 +3,19 @@ import numpy as np from agents.batched_agent import BatchedAgent class RandomAgent(BatchedAgent): - """This random agent just selects an action from the action space.""" def __init__(self, num_envs, num_actions): super().__init__(num_envs, num_actions) 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): + 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.postprocess_actions(actions) return actions \ No newline at end of file diff --git a/agents/rllib_agent.py b/agents/rllib_batched_agent.py similarity index 100% rename from agents/rllib_agent.py rename to agents/rllib_batched_agent.py diff --git a/submission_config.py b/submission_config.py index de7d56d..f7d5482 100644 --- a/submission_config.py +++ b/submission_config.py @@ -1,6 +1,6 @@ -from agents.random_agent import RandomAgent +from agents.random_batched_agent import RandomAgent # from agents.torchbeast_batched_agent import TorchBeastAgent -# from agents.rllib_agent import RLlibAgent +# from agents.rllib_batched_agent import RLlibAgent from submission_wrappers import addtimelimitwrapper_fn -- GitLab