in reply to shortest-path maze solver
Trailing newlines will confuse the noded code -- later I added a test for empty lines. Outputs:Maze#.1,1-7,7 ######### #.......# #.#.#.#.# ###...#.# #...#...# ##.###.## ##...#..# #######.# #########
which corresponds to the path marked in ?:(1, 1) (1, 2) (1, 3) (1, 4) (1, 5) (2, 5) (3, 5) (4, 5) (4, 6) (5, 6) +(6, 6) (6, 7) (7, 7)
which is indeed the shortest path from (1, 1) to (7, 7). Note that there are walls around the maze; that is because the universe is toroidal in shape, that is, (0, 0) is next to (0, -1) which is the same (in this case) as (0, 8).######### #?????..# #.#.#?#.# ###..?#.# #...#??.# ##.###?## ##...#??# #######?# #########
The maze header is simply "Maze", followed by the character for walls, the character for floors, entrance row, comma, entrance column, comma, dash, exit row, comma, exit column, newline.
|
|---|