#MazeRunner
A program I made for an assignment in second year. Takes an ascii maze as input and returns (i) the size of the maze, (ii) the set of all reachable squares, (iii) the minimum number of steps required to get to each square, and (iv) the fastest possible solution.
To compile: gcc MazeRunner.c -o MazeRunner
To run: ./MazeRunner < name_of_maze.txt
Many different test inputs have been made available.
- just1wall, just1open, and longlong are there as test cases to ensure the program is functioning correctly
- small_maze, medium_maze, and big_maze are more fun, and hard to solve by eye.
Note that to make the answers more readable, only the last two digits of every even number is printed. For example, here is the stage 4 output for the medium maze:
Stage 4
=======
maze solution
##########################################################################################################################################00 ##
## ## ..50..48..46..44..42..40..##..32..30..28..26..24.. ## ## ..38..36..34..32.. ##.. ##
## ## 52################## 38##34 ########## 22################## ########## 40########## 30########## ##02 ##
## ..54..56..58..60..## ..36.. ## ## ..20..18..16.. ## ..## ## ..## ##.. ##
################## ## 62################## ##################14 ########## ## 42## ## 28##################04 ##
## ..18..16..## ## ..64..66..68..70..72..74..## ..08..10..12.. ## ## ## ..## ## ..26..24..22.. ##.. ##
## 20## 14########################## ## 76## 06################## ########## 44## ##################20 ##06 ##
## ..## ..12..10..08..06..04..02..## ## ..## ..04..02..## ## ..46..48..50..52..## ..18.. ##.. ##
## 22########################## 00########## 78########## 00## ########## ################## 54## 16##########08 ##
## ..24..26..28..30..## ..## ## ..80.. ## ..## ##..04..02..00..98..96..## ..## ..14..12..10.. ##
## ########## 32########## 98## ##########82 ## 98##################06 ## ## 94## 56##########################
## ## ..34..36..## ..## ##..86..84.. ## ..96..94..## ..08.. ## ## ..## ..58..60..## ##
########################## 38## 96## ##88 ################## 92## 10########## ## 92########## 62########## ##
## ..82..80..78.. ## ..## ..94..92..90.. ## ## ..## ..12..14..## ## .. ## ..64..66..68.. ##
## 84##########76 ## 40################## ########## ## 90########## 16########## 90##########################70 ##
## ..## ..74.. ## ..42..44..46.. ## ## ..88.. ## ..## ## ..88..86..84..82..80..78..##.. ##
## 86## 72################## ##48 ########## ##################86 ## 18## ########################## 76##72 ##
## ..## ..70..68..66..64..## ##.. ## ## ## ..80..82..84.. ## ..20..22..24..26..28..30..## ## ..74.. ##
## 88################## 62## ##50 ## ########## 78################## ################## 32## ##################
## ..## ## ..## ##.. ## ..76..74..72..70..## ##..58..56..54..## ..34..36..38.. ##
## 90## ########## 60##########52 ########## ################## 68##########60 ## 52##################40 ## ##
## ..## ..58..56..54.. ## ## ..66..64..62.. ## ..50..48..46..44..42.. ## ##
## 92##########################################################################################################################################
The total length of this solution is 392, not 92.
Constructing your own mazes is easy - just use # for the walls and . for the traversible spaces.
Several of these test cases were adapted from the mazes presented at: https://www.asciiart.eu/art-and-design/mazes
Happy coding!
~Benjamin Metha, 2019