
CSC 145 - Programming Assignment 7: Solving a Maze
In this programming exercise you are to write a program to solve a maze represented as a rectangular two-
dimensional array of characters. Your program should display the maze array in its original form and then
with the solution path included.
Data Structure - You should create global variables to hold a maze array of up to 50 rows by 50 columns,
the start position, finish position and current position in the maze. An example data structure is shown
below:
TYPE Mazetype IS ARRAY(1..50,1..50) OF Character;
TYPE Position IS RECORD -- a structured data type to hold the row
Row : Integer; -- and column of a position in the maze
Col : Integer;
END RECORD;
Maze : Mazetype; -- rectangular array of size 50 x 50
Nrow,Ncol : Integer; -- actual size of maze array currently loaded
Start : Position; -- start position in maze
Finish : Position; -- finish or goal position in maze
This data structure is provided as an example only. You may use any appropriate structure in your program.
For example you might choose to represent positions start and finish as integer pairs rather than record
types.
Input - Your program should ask the user for the name of the file containing the maze description and then
load the maze array and other variables using the data in the specified text file. The format of the maze text
file is shown in the example below:
10 10 2 1 9 10 # of rows, # of columns, Start.Row, Start.Col, Finish.Row, Finish.Col
**********
* '*'= wall
**** *** * ' '=passage
* * *
* ** *** *
* * * *
**** * * *
* ** * ***
* *
**********
The first row of the maze text file contains numbers giving the size of the maze array, the starting position
and the finish position. Write a sub-procedure that reads the maze text file and loads the data into main
memory.
Display - Write a sub-procedure that displays the maze array on the monitor. Your display will be more
appealing if you include an extra blank after each maze character in the display. This is because the spacing
between characters is less than the spacing between rows.
********** * * * * * * * * * *
* *
**** *** * * * * * * * * *
* * * * * *
* ** *** * * * * * * * *
* * * * * * * *