-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbasic_env.py
39 lines (33 loc) · 957 Bytes
/
basic_env.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
from DSSE import DroneSwarmSearch
env = DroneSwarmSearch(
grid_size=40,
render_mode="human",
render_grid=True,
render_gradient=True,
vector=(1, 1),
timestep_limit=300,
person_amount=4,
dispersion_inc=0.05,
person_initial_position=(15, 15),
drone_amount=2,
drone_speed=10,
probability_of_detection=0.9,
pre_render_time=0,
)
def random_policy(obs, agents):
actions = {}
for agent in agents:
actions[agent] = env.action_space(agent).sample()
return actions
opt = {
"drones_positions": [(10, 5), (10, 10)],
"person_pod_multipliers": [0.1, 0.4, 0.5, 1.2],
"vector": (0.3, 0.3),
}
observations, info = env.reset(options=opt)
rewards = 0
done = False
while not done:
actions = random_policy(observations, env.get_agents())
observations, rewards, terminations, truncations, infos = env.step(actions)
done = any(terminations.values()) or any(truncations.values())