-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·35 lines (26 loc) · 975 Bytes
/
main.py
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
#! /usr/bin/env python3
import sys
import time
from generator.generator import *
from maze.maze import Cell
from render.renderer import Renderer
from solver.solver import *
import logging
def main():
logging.basicConfig(level=logging.INFO)
if len(sys.argv) < 2:
print("Invalid parameter(s) provided. Usage: main.py <maze_size>")
sys.exit(-1)
dim = int(sys.argv[1])
(maze, passed) = timed(RandomGenerator().generate, dim)
logging.info("Generation took {:0.3f} seconds".format(passed))
((src, dst, path), passed) = timed(DepthFirstSolver().solve, maze, Cell(0, 0), Cell(dim - 1, dim - 1))
logging.info("Solving took {:0.3f} seconds".format(passed))
logging.info("Result path is of length {}".format(len(path)))
Renderer().render(maze, src, dst, path)
def timed(method, *args):
start_time = time.time()
result = method(*args)
return result, time.time() - start_time
if __name__ == "__main__":
main()