From 155c718df6b6df2dcaa67856113f0de4fb9a0325 Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Wed, 22 Mar 2023 20:08:29 +0100 Subject: [PATCH] feat: update readme, add important and make pylint compliant --- IMPORTANT.txt | 8 ++++++++ README.txt | 13 +++++++++++++ main.py | 14 ++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 IMPORTANT.txt diff --git a/IMPORTANT.txt b/IMPORTANT.txt new file mode 100644 index 00000000..b80a31ca --- /dev/null +++ b/IMPORTANT.txt @@ -0,0 +1,8 @@ +Manhattan: +For: 1000 files, sum of path lengths = 122194, average path length = 122.194, sum_of_time = 0.8560767570011194, average time to solve: 0.0008560767570011194, heuristic_total_total_time: 0.10561735888813928, all_heuristic_called: 282721, average_heuristic_time: 3.735745094568118e-07 + +Euclidean: +For: 1000 files, sum of path lengths = 120936, average path length = 120.936, sum_of_time = 1.268625628994414, average time to solve: 0.001268625628994414, heuristic_total_total_time: 0.34228658579650073, all_heuristic_called: 276120, average_heuristic_time: 1.2396298196309602e-06 + +Random: +For: 1000 files, sum of path lengths = 131126, average path length = 131.126, sum_of_time = 1.2832818229990153, average time to solve: 0.0012832818229990153, heuristic_total_total_time: 0.07322999603366043, all_heuristic_called: 417262, average_heuristic_time: 1.7550123431719262e-07 \ No newline at end of file diff --git a/README.txt b/README.txt index aa1e675d..92816df8 100644 --- a/README.txt +++ b/README.txt @@ -4,4 +4,17 @@ python main.py you can specify the name of the file which stores maze by typing: python main.py mazeFile.txt +python main.py -h --help print help prompt + +python main.py -t --test non interactive (does not print steps) for testing +different heuristics, goes through entire generatedMazes folder and +compares heuristic speed and path length, saves solved mazes to solvedMazes folder + +python main.py -t --test [FOLDER] non interactive (does not print steps) for testing +different heuristics, goes through entire [FOLDER] folder and +compares heuristic speed and path length, saves solved mazes to solvedMazes folder + +python main.py -g --generate [NUMBER] - generates as many mazes as entered in +Number parameter and puts it in the generatedMazes folder + diff --git a/main.py b/main.py index 038f426f..95dcacd3 100644 --- a/main.py +++ b/main.py @@ -155,7 +155,7 @@ class MazeSolver: heuristic_time = end_time - start_time return heuristic, heuristic_time - def heuristic_random(self, position): + def heuristic_random(self): """Heuristic function that just returns random value between 0 and 1""" start_time = time.perf_counter() heuristic = random() @@ -301,9 +301,19 @@ def test_mode(): sum_of_paths += len(solved_path) save_maze(loaded_maze, True, solved_path, filename, 0) files_amount += 1 + if files_amount == 0: + print("no mazes found! Generate some using python main.py -g [NUMBER]") + sys.exit() average_path = sum_of_paths / files_amount average_time = sum_of_time / files_amount - print(f"For: {files_amount} files, sum of path lengths = {sum_of_paths}, average path length = {average_path}, sum_of_time = {sum_of_time}, average time to solve: {average_time}, heuristic_total_total_time: {heuristic_total_total_time}, all_heuristic_called: {all_heuristic_called}, average_heuristic_time: {heuristic_total_total_time / all_heuristic_called}") + print(f"""For: {files_amount} files, + sum of path lengths = {sum_of_paths}, + average path length = {average_path}, + sum_of_time = {sum_of_time}, + average time to solve: {average_time}, + heuristic_total_total_time: {heuristic_total_total_time}, + all_heuristic_called: {all_heuristic_called}, + average_heuristic_time: {heuristic_total_total_time / all_heuristic_called}""") def default(): """ Runs default operation - reads, solves and prints single maze from file """