Technology Sharing

Recursive maze problem -java

2024-07-11

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

1) The findWay method is used to find a path out of the maze. If found, it returns true, otherwise it returns false
2) (i, j) is the position of the mouse, the initial position is (1, 1)
3) Because it is a recursive path search, the meaning of each value in the map array is first defined:
0 means you can go, 1 means there is an obstacle, 2 means you can go, 3 means you have walked but cannot go through.
4) If map[6][5]==2, it means that a path has been found and we can end the search. Otherwise, we continue to search.
5) First determine the path-finding strategy -