Solving maze path based on exhaustive method

General
The procedure is divided into three parts. The first part is processing data: abstracting the maze into a data type that is needed and the computer can handle, in fact, is to abstract a maze into a two-dimensional array, and record the positions that can be walked as 1, and the positions that cannot be walked. Recorded as 0; the second part is the input maze (I have input the boundary of the maze in the program, so I only need to input the internal situation of the maze); the third part is to record the correct pathfinding path: because the maze is recorded When looking for a path, you may find a dead end. At this time, you need to delete the position at this time and return to the previous position. At this time, you must use a data structure (stack) that meets the "first in, last out" rule. The judgment of whether you have reached a dead end depends on whether the effective direction found corresponds to the direction when you came. If the effective direction found corresponds to the direction when you came, this place is a dead end, otherwise there is a way to go.

                      算法有待优化

The source code is as follows: the
Maze wayfinding
test data is as follows:
Test Data

Guess you like

Origin blog.csdn.net/ownplace/article/details/108906697