-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_all.py
27 lines (23 loc) · 929 Bytes
/
run_all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import levdoom
from levdoom import Scenario
def main():
max_steps = 50
for name, scenario in Scenario.__members__.items():
print("Running scenario", name.lower())
for level in range(5):
print("Running level", level)
level_envs = levdoom.make_level(scenario, level=level, max_steps=max_steps)
for env in level_envs:
env.reset()
total_reward = 0
for i in range(max_steps):
action = env.action_space.sample()
state, reward, done, truncated, info = env.step(action)
env.render()
total_reward += reward
if done or truncated:
break
print(f"{env.unwrapped.name} finished in {i + 1} steps. Reward: {total_reward:.2f}")
env.close()
if __name__ == '__main__':
main()