feat: update readme, add important and make pylint compliant

This commit is contained in:
Krzysztof Rudnicki 2023-03-22 20:08:29 +01:00
parent 3906b877d9
commit 155c718df6
3 changed files with 33 additions and 2 deletions

8
IMPORTANT.txt Normal file
View File

@ -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

View File

@ -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

14
main.py
View File

@ -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 """