Python script for solving text based mazes.
Instead of calculating every point in the queue, this script gives priority to nearest points and saves time.
maze.py script
- takes a text file that contains maze data,
- solves it,
- writes the solution to output file.
python3 maze.py
Uses default values below.
Input file: maze.txt
Output file: maze-solved.txt
Move limit: 5_000
python3 maze.py [input_file] [output_file]
Example:
python3 maze.py maze.txt maze-solved.txt
python3 maze.py [input_file] [output_file] [move_limit]
Example:
python3 maze.py maze.txt maze-solved.txt 10_000
The maze data of the input and output text files consist of these symbols.
#: Wall
S: Starting point
T: Target point
spaces: Spaces.
numbers: Solution path. Repeating cycle of numbers: [0-9].
dots: Calculated but neglected points.
X: Blocked point. Cannot move forward. Turns into dot after solution.
O: Prepending point. Waiting to be calculated. Turns into dot after solution.
###########
#S #
# #
###### ####
#T #
###########
###########
#S..... #
#012345. #
######6####
#T10987. #
###########
###########
#SXO #
#XXXO #
###### ####
#T #
###########