-
Notifications
You must be signed in to change notification settings - Fork 1
/
play.py
52 lines (35 loc) · 1.05 KB
/
play.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
37
38
39
40
41
42
43
44
45
46
47
48
49
import tensorflow as tf
import gym
import cv2
import numpy as np
from ppo import MlpPPO
from config import *
NUM_OF_GAMES = 100
env = gym.make(args.environment)
action_space = env.action_space
observation_space = env.observation_space
action_bound = [env.action_space.low, env.action_space.high]
global_episodes, global_update_counter = 0, 0
x_t = env.reset()
play_network = MlpPPO(action_space, observation_space,'Chief', args)
sess = tf.InteractiveSession()
saver = tf.train.Saver(max_to_keep=5)
play_network.load_model(sess, saver)
score = 0
game_no = 1
total_sore = []
while True:
env.render()
action = play_network.choose_action(x_t, sess)
x_t, r_t, terminal, info = env.step(action)
score += r_t
if terminal:
print('Game No : '+ str(game_no)+ ', Score : ', score)
x_t = env.reset()
game_no += 1
total_sore.append(score)
score = 0
if game_no == NUM_OF_GAMES + 1:
break
avarage_score = np.vstack(total_sore).mean()
print('Avarage Score in 100 Games : ' + str(avarage_score))