ai-lab-one/main.py

26 lines
809 B
Python
Raw Normal View History

2023-02-12 16:48:56 +00:00
#!.venv/bin/python
# I am but a silly little NixOS user who cannot use normal shebangs
2023-02-11 22:08:26 +00:00
from emis_funky_funktions import *
from sys import argv
from operator import eq
2023-02-12 04:58:01 +00:00
from a_star import pathfind_multi
2023-02-12 16:10:07 +00:00
from read_in import load_points, load_world_from_paths
2023-02-11 22:08:26 +00:00
from world import Point, World
2023-02-12 04:58:01 +00:00
from write_out import save_map
2023-02-11 22:08:26 +00:00
2023-02-12 16:10:07 +00:00
def main(terrain_path: str, elevation_path: str, checkpoints_path: str, image_output: str):
2023-02-12 04:58:01 +00:00
world = unwrap_r(load_world_from_paths(terrain_path, elevation_path))
2023-02-12 16:10:07 +00:00
checkpoints = unwrap_r(load_points(checkpoints_path))
2023-02-12 04:58:01 +00:00
maybe_path = pathfind_multi(
world.neighbors,
world.heuristic,
2023-02-12 16:10:07 +00:00
checkpoints
2023-02-11 22:08:26 +00:00
)
2023-02-12 04:58:01 +00:00
path, cost = unwrap_opt(maybe_path)
2023-02-12 16:50:11 +00:00
print(f'Path found! Estimated time: {cost//60_000_000} minutes')
2023-02-12 16:10:07 +00:00
save_map(image_output, world, path)
2023-02-11 22:08:26 +00:00
if __name__ == '__main__':
main(*argv[1:])