Newer
Older
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
import math
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import random
"""
Helper Functions
"""
def create_random_starts_and_goals(env, num_agents):
"""
Given some map file, create a set of starts and goals for the specified
number of agents. This function will create a file folowing the agent file format.
"""
starts = []
goals = []
for i in range(num_agents):
# generate a random start
x = random.uniform(env.x_range[0], env.x_range[1])
y = random.uniform(env.y_range[0], env.y_range[1])
while [x,y] in starts:
x = random.uniform(env.x_range[0], env.x_range[1])
y = random.uniform(env.y_range[0], env.y_range[1])
starts.append([x,y])
# generate a random goal
x = random.uniform(env.x_range[0], env.x_range[1])
y = random.uniform(env.y_range[0], env.y_range[1])
while [x,y] in goals:
x = random.uniform(env.x_range[0], env.x_range[1])
y = random.uniform(env.y_range[0], env.y_range[1])
goals.append([x,y])
return starts,goals
def read_agents_from_file(fname):
pass
def generate_random_agents(num_agents):
pass
def read_environment_from_file(fname):
pass