mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-18 04:49:12 +00:00
Unbreak random_agent (#406)
The semantics of `env.reset()` have changed. It's no longer possible to reset an environment until it's done. Notably, this commit changes the behavior of random_agent. It used to have a limit on number of actions per episode. If we wanted that now, we'd have to close the environment and recreate it on each episode, which may be slow.
This commit is contained in:
committed by
Greg Brockman
parent
057862d83f
commit
8676fa858f
@@ -48,14 +48,12 @@ if __name__ == '__main__':
|
||||
agent = RandomAgent(env.action_space)
|
||||
|
||||
episode_count = 100
|
||||
max_steps = 200
|
||||
reward = 0
|
||||
done = False
|
||||
|
||||
for i in range(episode_count):
|
||||
ob = env.reset()
|
||||
|
||||
for j in range(max_steps):
|
||||
while True:
|
||||
action = agent.act(ob, reward, done)
|
||||
ob, reward, done, _ = env.step(action)
|
||||
if done:
|
||||
|
Reference in New Issue
Block a user