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 21:19:13 +00:00
|
|
|
print('All files loaded, begining search...')
|
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 21:19:13 +00:00
|
|
|
print(f'Path found!\n\nEstimated time: {cost//60_000_000} minutes')
|
|
|
|
path_length = unwrap_r(world.calculate_path_length(path))
|
|
|
|
print(f'Estimated length: {path_length/1_000_000:.1f} kilometers')
|
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:])
|