A maze is a networks of paths in which it is hard to find the exit.
What you must do
You must code a maze game in a 2D array of 20 rows by 30 columns. The player starts at an index of
the 2D array, at one of the edges of the array, and the exit of the maze is on another index, at another
edge of the array. The player wins as soon as he or she reaches the exit.
Note: you must use functions, and at least 2 functions must be recursive.
The maze’s representation in the 2D array
To simplify things, the game will be printed to the screen with textual characters. And so, the player
will be represented by a P, the exit will be represented by an E, an obstacle will be represented by an X,
and a path will be represented by a space.
Your program, step by step
First, the 2D array is shown (printed) on the screen, showing the player, the exit, the obstacles, and
Second, you use a prompt to ask the player to enter a direction, using the following message:
Which way do you want to go?
The direction entered by the player can be: up, down, left, or right. The directions can also be
represented by the letters u, d, l, r.
If the player's input is invalid, either because it is not one of the valid words (or letters) or because the
direction entered goes into an obstacle or outside the array, you print the message “invalid
direction” to the screen and you ask the player for a direction again.
If the player's input is valid, you move on the to the next step.
Third, the 2D array is shown (printed) on the screen again with all of its information, showing the
player in his/her new position, the exit, the obstacles, and the paths.
Fourth, the program detects if the player (P) has reached the exit (E). If yes, then the message “You
have reached the exit!” is shown on the screen, and the program ends. If the player has not
reached the exit, the program goes back to the second step.