-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmake_videos.py
More file actions
49 lines (36 loc) · 939 Bytes
/
make_videos.py
File metadata and controls
49 lines (36 loc) · 939 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import gameworld.envs # this import triggers the register() calls
import gymnasium
num_steps = 500
games = [
"Aviate",
"Bounce",
"Cross",
"Drive",
"Explode",
"Fruits",
"Gold",
"Hunt",
"Impact",
"Jump",
]
renders = {}
for game in games:
env = gymnasium.make(f"Gameworld-{game}-v0")
obs, info = env.reset()
all_obs = [obs]
for t in range(num_steps):
# random actions as example
action = env.action_space.sample()
# step env
obs, reward, done, truncated, info = env.step(action)
# reset when done
if done:
obs, info = env.reset()
all_obs.append(obs)
renders[game] = all_obs
import mediapy as mp
from pathlib import Path
Path("./gameworld_videos").mkdir(parents=True, exist_ok=True)
with mp.set_show_save_dir("./gameworld_videos"):
# Show videos
mp.show_videos(renders, codec="gif", width=200)