-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_ocatari.py
36 lines (31 loc) · 997 Bytes
/
demo_ocatari.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
28
29
30
31
32
33
34
35
36
import random
from ocatari.core import OCAtari
from ocatari.utils import load_agent, parser
GAME_NAME = "Pong"
MODE = "revised"
HUD = False
env = OCAtari(GAME_NAME, mode=MODE, hud=HUD, obs_mode='dqn')
observation, info = env.reset()
opts = parser.parse_args()
if opts.path:
agent = load_agent(opts, env.action_space.n)
for i in range(10000):
if opts.path is not None:
action = agent.draw_action(env.dqn_obs)
else:
action = random.randint(0, 0)
obs, reward, terminated, truncated, info = env.step(action)
# if i % 10 == 0:
# print(env.objects)
# for obj in env.objects:
# x, y = obj.xy
# if x < 160 and y < 210:
# opos = obj.xywh
# ocol = obj.rgb
# sur_col = make_darker(ocol)
# mark_bb(obs, opos, color=sur_col)
# env.render()
if terminated or truncated:
print('episode finished', i)
observation, info = env.reset()
env.close()