blob: faa7e968d4c6172bbd9b8ef4e05438e8ef18aab8 (
plain)
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
|
#!/usr/bin/env python3
from graph import Graph
from parser import Parser
from pathfinder import Pathfinder
from scheduler import Scheduler
import sys
from visualiser import Visualiser
def main() -> None:
"""Parse a map,
create a graph,
find the shortest path,
run the simulation through the scheduler
"""
if len(sys.argv) != 2:
print("Usage: './main.py <map_file>' or 'make run MAP=path/to/map'")
return
try:
parser = Parser()
drone_map = parser.parse_map()
graph = Graph(drone_map)
pathfinder = Pathfinder(graph)
result = pathfinder.find_path(
drone_map.start.name,
drone_map.end.name,
)
if result is None:
print("No valid path found.")
return
scheduler = Scheduler(
graph=graph,
path=result.path,
number_of_drones=drone_map.nb_drones,
)
scheduler.run()
# Visualiser(graph, drone_map, scheduler).run()
except Exception as e:
print(e)
if __name__ == "__main__":
main()
|