summaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
authoryctct <yctct@yctct.com>2026-11-25 17:56:21 +0100
committeryctct <yctct@yctct.com>2026-11-25 17:56:21 +0100
commit489b223db74f468032c1eeb6ca18ee6a4da3bc33 (patch)
treea360664813443859ebfc0dcce79dec7fddf93c9f /src/main.py
Add files, first commit
Diffstat (limited to 'src/main.py')
-rw-r--r--src/main.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main.py b/src/main.py
new file mode 100644
index 0000000..faa7e96
--- /dev/null
+++ b/src/main.py
@@ -0,0 +1,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()