-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (41 loc) · 1.62 KB
/
main.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
50
"""
### NOTICE ###
You DO NOT need to upload this file
"""
import argparse
from test import test
from environment import Environment
import time
def parse():
parser = argparse.ArgumentParser(description="DS595/CS525 RL PRoject4")
parser.add_argument('--env_name', default=None, help='environment name')
parser.add_argument('--train_dqn', action='store_true', help='whether train DQN')
parser.add_argument('--test_dqn', action='store_true', help='whether test DQN')
try:
from argument import add_arguments
parser = add_arguments(parser)
except:
pass
args = parser.parse_args()
return args
def run(args):
start_time = time.time()
if args.train_dqn:
env_name = args.env_name or 'BreakoutNoFrameskip-v4'
env = Environment(env_name, args, atari_wrapper=True, test=False)
from agent_dqn import Agent_DQN #Double DUEL DQN
# from agent_dqn_epi import Agent_DQN # Duel DQN eith different epsilon decay
# from agent_dqn_duel import Agent_DQN #DUEL DQN
agent = Agent_DQN(env, args)
agent.train()
if args.test_dqn:
env = Environment('BreakoutNoFrameskip-v4', args, atari_wrapper=True, test=True)
from agent_dqn import Agent_DQN #Double DUEL DQN
# from agent_dqn_epi import Agent_DQN # Duel DQN eith different epsilon decay
# from agent_dqn_duel import Agent_DQN #DUEL DQN
agent = Agent_DQN(env, args)
test(agent, env, total_episodes=100, record_video=True)
print('running time:',time.time()-start_time)
if __name__ == '__main__':
args = parse()
run(args)