Tino APCS

Defining the Maze Problem

  1. The maze will be defined as a 2-D grid of asterisks (marking walls) and blanks (marking potential paths). The size of the grid will be 12 x 12 and the starting location will be at 6, 6.

  2. The data structure for this problem will be a 2-dimensional array of char. The array will be declared as a 13 x 13 grid so that we can use locations 1..12 by 1..12. Row 0 and column 0 will not be used in the data structure.

  3. The initial grid is stored as a text file and will be loaded into the array.

    (Here is a copy of the mazeData.txt file)

  4. The solution is a backtracking algorithm involving a series of trial and error attempts. A potential path out of the maze will be traced with a !, with moves limited to horizontal or vertical directions. If a dead-end is encountered, back up and try a different direction.

  5. We will be at an exit point if we arrive at row 1 or MAXROW, or at column 1 or MAXCOL.

Last modified: March 04, 2023

Dark Mode

Outline