mirror of
https://github.com/wassname/ray.git
synced 2026-08-11 05:51:40 +08:00
[RLlib] Issue 8319 DDPG (MA or num_envs_per_worker > 1) broken. (#8324)
This commit is contained in:
+4
-7
@@ -12,24 +12,21 @@ class SimpleCorridor(gym.Env):
|
||||
self.end_pos = config["corridor_length"]
|
||||
self.cur_pos = 0
|
||||
self.action_space = Discrete(2)
|
||||
self.observation_space = Box(
|
||||
0.0, self.end_pos, shape=(1, ), dtype=np.float32)
|
||||
self.observation_space = Box(0.0, 999.0, shape=(1, ), dtype=np.float32)
|
||||
|
||||
def set_corridor_length(self, length):
|
||||
self.end_pos = length
|
||||
self.observation_space = Box(
|
||||
0.0, self.end_pos, shape=(1, ), dtype=np.float32)
|
||||
print("Updated corridor length to {}".format(length))
|
||||
|
||||
def reset(self):
|
||||
self.cur_pos = 0
|
||||
self.cur_pos = 0.0
|
||||
return [self.cur_pos]
|
||||
|
||||
def step(self, action):
|
||||
assert action in [0, 1], action
|
||||
if action == 0 and self.cur_pos > 0:
|
||||
self.cur_pos -= 1
|
||||
self.cur_pos -= 1.0
|
||||
elif action == 1:
|
||||
self.cur_pos += 1
|
||||
self.cur_pos += 1.0
|
||||
done = self.cur_pos >= self.end_pos
|
||||
return [self.cur_pos], 1 if done else 0, done, {}
|
||||
|
||||
Reference in New Issue
Block a user