feat: readme and ability to specify mazeFile name

This commit is contained in:
Krzysztof Rudnicki 2023-03-22 11:14:38 +01:00
parent 06d1f807e0
commit c73c52b91c
2 changed files with 14 additions and 1 deletions

7
README.txt Normal file
View File

@ -0,0 +1,7 @@
To run the program install python, go to project repository and just run python main.py:
python main.py
you can specify the name of the file which stores maze by typing:
python main.py mazeFile.txt

View File

@ -26,6 +26,8 @@ Does not work if no path (Should print out NO PATH FOUND)
import heapq
import sys
class MazeSolver:
# self corresponds to "this" in js, it refers to object of MazeSolver class
@ -147,8 +149,12 @@ def print_maze(maze, path=None):
# Ran first in the code
if __name__ == '__main__':
print (sys.argv)
file_name = 'maze.txt'
if len(sys.argv) > 1:
file_name = sys.argv[1]
# Open and load text file to array
maze = load_maze('mazes/mazeDeadEnd.txt')
maze = load_maze(file_name)
# Initialize MazeSolver object with maze as paramater
solver = MazeSolver(maze)
# Find path using MazeSolver solve method