if __name__ == "__main__": if len(args.all) < 3: print("Usage:\nPYTHONPATH=. python3 demos/terminal_demo.py <rows> <columns> <algorithm> ", end="") print("[--exporter=<exporter>] [--rotations=<rotations>] [--pathfinding]") print("Valid algorithms: {}".format("|".join([algorithm.__name__ for algorithm in ALGORITHMS]))) print("Valid exporters: {}".format("|".join(AVAILABLE_EXPORTERS))) print("Rotations is an integer value measuring number of 90 degree clockwise rotations to perform") print("Pathfinding flag shows distances between cells") exit(1) exporter, exporter_name = get_exporter(AVAILABLE_EXPORTERS, DEFAULT_EXPORTER) rotations = get_rotations() pathfinding = get_pathfinding() rows = int(args.all[0]) columns = int(args.all[1]) algorithm = get_algorithm() print("Algorithm: {}\nRows: {}\ncolumns: {}\nExporter: {}".format(algorithm.__name__, rows, columns, exporter_name)) print("90deg Rotations: {}\nPathfinding: {}".format(rotations, pathfinding)) if pathfinding: grid = DistanceGrid(rows, columns) # type: Union[Grid, DistanceGrid] else: grid = Grid(rows, columns) grid = algorithm.on(grid) for num in range(rotations): grid = Rotator.on(grid) if pathfinding: start_row, start_column, end_row, end_column = LongestPath.calculate(cast(DistanceGrid, grid))
parser.add_argument( "-r", "--rotations", type=int, default=0, help="number of 90 degree clockwise rotations to perform") parser.add_argument("-p", "--pathfinding", type=str2bool, default=False, help="whether solve the maze") args = parser.parse_args() rows = args.rows columns = args.columns algorithm = get_algorithm(args.algorithm, AVAILABLE_ALGORITHMS) exporter = get_exporter(args.exporter, AVAILABLE_EXPORTERS) rotations = args.rotations pathfinding = args.pathfinding print("Algorithm: {}\nRows: {}\ncolumns: {}\nExporter: {}".format( args.algorithm, rows, columns, args.exporter)) print("90deg Rotations: {}\nPathfinding: {}".format( rotations, pathfinding)) grid = DistanceGrid(rows, columns) algorithm.on(grid) for num in range(rotations): grid = cast(DistanceGrid, Rotator().on(grid)) if pathfinding: