This repository has been archived by the owner on Jun 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestEnv.py
77 lines (57 loc) · 2.4 KB
/
TestEnv.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from MapGenerators.Basic import Basic
from MapGenerators.Corners import Corners
from MapGenerators.Dome import Dome
from MapGenerators.Floors import Floors
from MapGenerators.HighPlatform import HighPlatform
from MapGenerators.Pyramid import Pyramid
from MapGenerators.Split import Split
from MapGenerators.TwoFloors import TwoFloors
from MapGenerators.TwoHighTowers import TwoHighTowers
from MapGenerators.TwoTowers import TwoTowers
from Players.Circle import Circle
from Players.Rectangle import Rectangle
from Simulator.Geofriends2 import GeometryFriends2
agent_rectangle = Rectangle(can_interrupt_growth=False)
agent_circle = Circle()
circle_maps = [Basic(), HighPlatform(), Corners(), Pyramid(), TwoTowers()]
rect_maps = [Basic(), HighPlatform(), Floors(), TwoFloors()]
all_maps = [Basic(), TwoHighTowers(), Split(), Dome()]
environment = GeometryFriends2([agent_rectangle, agent_circle], all_maps,
agent_collision=True)
for trial_number in range(3):
observation, additional_information = environment.reset()
while True:
action = environment.action_space.sample() # take a random action
observation, reward, terminal, additional_information = environment.step(action) # step
if reward != 0:
print("Got " + str(reward) + " points")
if terminal:
print("Episode over")
break
environment.close()
####
environment = GeometryFriends2([agent_rectangle], rect_maps)
for trial_number in range(3):
observation, additional_information = environment.reset()
while True:
action = environment.action_space.sample() # take a random action
observation, reward, terminal, additional_information = environment.step(action) # step
if reward != 0:
print("Got " + str(reward) + " points")
if terminal:
print("Episode over")
break
environment.close()
####
environment = GeometryFriends2([agent_circle], circle_maps)
for trial_number in range(3):
observation, additional_information = environment.reset()
while True:
action = environment.action_space.sample() # take a random action
observation, reward, terminal, additional_information = environment.step(action) # step
if reward != 0:
print("Got " + str(reward) + " points")
if terminal:
print("Episode over")
break
environment.close()