Reference no: EM13164957
A maze can be represented with a two-dimensional array in which nonzero entries are walls and zero entries are passages. When printing a maze, nonzero entries could be printed as X's, and zero entries as spaces. As a path is being traced through the maze, it could be represented with 0's. For example, a 30*20 maze would look like this:
**********************************
00** *** *
* 0** ********** ******** *
*000** ** ******* * *
* **0** ** ** * ** *** *
****0** ** ** * * * *
**000**0******* ** ** *** *
*00****0** *** ** ** *
*0*****0** *** ** ** *
*0000000** *** ** ** ******
************* *** ** ** ***
** * * ** ** **** **
** * * ** ** ** **
** **** **
***** ******* *** **
* **** ****** *** **
* ********** ***** *** **
* * ** ***** *** **
**** *** ***** **
**********************************
Write a program that will read in such an array, and repeatedly prints it so the user can select the direction in which to move next. The user's requested move can prompt a number of responses:
-A wall blocks the way
-A step forward from the current cell to one not visited before
-A step backward from the current cell to one visited previously
-A giant step forward: found the exit!