-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsimple_agent.py
45 lines (33 loc) · 914 Bytes
/
simple_agent.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
import numpy as np
IMG_WIDTH = 160
IMG_HEIGHT = 90
SENSOR_DIM = 4
ACTION_DIM = 2
LINEAR_VEL_DIM = 0
ANGULAR_VEL_DIM = 1
class RandomAgent:
def __init__(self):
pass
def reset(self):
pass
def act(self, observations):
action = np.random.uniform(low=-1, high=1, size=(ACTION_DIM,))
return action
class ForwardOnlyAgent(RandomAgent):
def act(self, observations):
action = np.zeros(ACTION_DIM)
action[LINEAR_VEL_DIM] = 1.0
action[ANGULAR_VEL_DIM] = 0.0
return action
if __name__ == "__main__":
obs = {
'depth': np.ones((IMG_HEIGHT, IMG_WIDTH, 1)),
'rgb': np.ones((IMG_HEIGHT, IMG_WIDTH, 3)),
'sensor': np.ones((SENSOR_DIM,))
}
agent = RandomAgent()
action = agent.act(obs)
print('action', action)
agent = ForwardOnlyAgent()
action = agent.act(obs)
print('action', action)