-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoadPlay.py
37 lines (24 loc) · 853 Bytes
/
LoadPlay.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
import time
import mss as mss
from stable_baselines3 import DQN, A2C, PPO
from stable_baselines3.common.evaluation import evaluate_policy
from FlappyBirdEnv import FlappyGame
env = FlappyGame()
env.reset()
models_dir = "models/PPO"
log_dir = "logs"
model_path = f"{models_dir}/PPO_650000_steps.zip"
model = PPO.load(model_path,env=env, tensorboard_log=log_dir, device="cuda", buffer_size=10_000)
# Random decisions
for episode in range(100):
obs = env.reset()
terminated = False
total_reward = 0
while not terminated:
action, _ = model.predict(obs, deterministic=True)
obs, reward, terminated, info = env.step(action)
time.sleep(0.01)
total_reward += reward
print('Total Reward for episode {} is {}'.format(episode, total_reward))
time.sleep(1)
env.close()