This paper aims to investigate and solve maze-solving problems by implementing the Breadth-First Search (BFS) algorithm and the Left-Hand Wall-Following algorithm, providing references for maze navigation of small embedded robots. In this study, the OCaml programming language is adopted. This paper implements both the BFS and Left-Hand Wall-Following algorithms to solve three mazes of different sizes (30×28, 30×17, 30×16). The total moving steps and the shortest valid paths are recorded. The time and space complexity of the two algorithms are calculated, and comparative tables are generated for analysis. Experiments show that the Left-Hand Wall-Following algorithm has a constant space complexity of O(1) with stable memory consumption. However, its generated path length can reach 2.5 to 10 times the theoretical shortest path, and it is only applicable to simple mazes. In contrast, BFS can stably output globally optimal paths and adapt to all types of complex mazes, yet its memory overhead grows linearly with maze size. The two algorithms fit distinct application scenarios and can be selected flexibly according to equipment memory constraints and requirements for optimal paths.
Research Article
Open Access