-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdemo_random.py
38 lines (32 loc) · 1.22 KB
/
demo_random.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
import numpy as np
import os
import sys
import random
from sge.mazeenv import MazeEnv
from sge.utils import KEY
###################
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--game_name', default='mining',
help='MazeEnv/config/%s.lua')
parser.add_argument('--graph_param', default='train_1',
help='difficulty of subtask graph')
parser.add_argument('--game_len', default=70,
type=int, help='episode length')
parser.add_argument('--seed', default=1, type=int,
help='random seed')
parser.add_argument('--gamma', default=0.99, type=float,
help='discount factor')
args = parser.parse_args()
env = MazeEnv(args.game_name, args.graph_param,
args.game_len, args.gamma)
env.reset(args.seed)
action_set = env.get_actions()
step, done = 0, False
while not done:
action = random.sample(list(action_set), 1)[0]
state, rew, done, info = env.step(action)
string = 'Step={:02d}, Action={}, Reward={:.2f}, Done={}'
print(string.format(step, action, rew, done))
step += 1