forked from openai/gym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (30 loc) · 994 Bytes
/
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
import argparse
import sys
import gym
from gym import wrappers, logger
import gym_snake
import agents
from agents.random import RandomAgent
from agents.dqnagent import DQNAgent
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=None)
parser.add_argument('env_id', nargs='?', default='snake-v0', help='Select the environment to run')
args = parser.parse_args()
# You can set the level to logger.DEBUG or logger.WARN if you
# want to change the amount of output.
logger.set_level(logger.INFO)
env = gym.make(args.env_id)
env.seed(0)
agent = DQNAgent(env.action_space)
episode_count = 1000
reward = 0
done = False
for i in range(episode_count):
ob = env.reset()
while True:
# print(ob) # Shows ascii representation
action = agent.act(ob, reward, done)
ob, reward, done, _ = env.step(action)
if done:
break
# env.render()