mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 16:23:11 +02:00
feat: readme and ability to specify mazeFile name
This commit is contained in:
parent
06d1f807e0
commit
c73c52b91c
7
README.txt
Normal file
7
README.txt
Normal 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
|
||||
|
||||
|
||||
8
main.py
8
main.py
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user