-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRun.py
More file actions
37 lines (29 loc) · 823 Bytes
/
Run.py
File metadata and controls
37 lines (29 loc) · 823 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
import retro
import gym
from RandomAgent import TimeLimitWrapper
from stable_baselines3 import PPO
from stable_baselines3.common.atari_wrappers import MaxAndSkipEnv
model = PPO.load("tmp/best_model.zip")
def main():
steps = 0
#env = retro.make(game='MegaMan2-Nes')
env = retro.make(game='SuperMarioBros-Nes')
env = TimeLimitWrapper(env)
env = MaxAndSkipEnv(env, 4)
obs = env.reset()
done = False
while not done:
action, state = model.predict(obs)
obs, reward, done, info = env.step(action)
env.render()
if done:
obs = env.reset()
steps += 1
if steps % 1000 == 0:
print(f"Total Steps: {steps}")
print(info)
print("Final Info")
print(info)
env.close()
if __name__ == "__main__":
main()