-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolicyAgent.py
41 lines (36 loc) · 1.19 KB
/
policyAgent.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 time
import calculations
from solarescape_env import *
from ple import PLE
game = SolarescapeEnv(width=856, height=856, dt=5)
game.screen = pygame.display.set_mode(game.getScreenDims(), 0, 32)
p = PLE(game, fps=30, display_screen=False)
class PolicyAgent():
def __init__(self, actions):
self.actions = actions
def getState(self):
state = {
"agent_y": self.agent.pos.y,
"agent_x": self.agent.pos.x,
"agent_velocity_x": self.agent.vel.x,
"agent_velocity_y": self.agent.vel.y
}
return state
def pickAction(self):
state = getState()
if
(return self.actions[np.random.randint(0, len(self.actions))]
if __name__ == '__main__':
print(game.getActions())
na = NaiveAgent(list(game.getActions()))
for i in range(100):
# ob = game.init()
while True:
p.act(na.pickAction())
# if (int(time.time()) % 5 == 0):
# action = na.pickAction()
# #action = na.actions[2]
# #print(action)
# p.act(action)
# else:
# p.act(None)