Question: python All content or needed information can be found throughout the picture. 3. Escaping the Maze. The walls of the maze are indicated by asterisks
3. Escaping the Maze. The walls of the maze are indicated by asterisks (#), shown in Figure 1. # # # ## # ## ## # # #S # # # # # # # # # # # # # # # # # # # # # # # # # R # # # # # # # # # # Figure 1: The maze is on a grid-based map. The origin is denoted by the letter 'R', this is location (1,1). The entrance or 'S'is (1.8) and the exit or 'E' is (7,0) # # The entrance to the maze is located at the top left corner (S) and the exit at the lower right corner (E). Treat the interior of the maze as a 2D grid map, where the exterior walls are ignored and location (1.1) is denoted by the letter 'R'. Write a recursive function, escape (loc), that returns true if it's possible to travel from position loc to the exit. Use the following recursive approach to check whether you can escape from the maze: if you are at an exit, return True. Recursively check whether you can escape from one of the empty neighbouring locations without visiting the current location. Also, your solution should represent locations as lists, e.g., [1.1), not as tuples, e.g., (1,1). Some locations within the maze shown in Figure 1 are traps, for example, there is no way to get to the exit from (7,5). Make sure to include such a location when testing your program. In order to complete your assignment, you will need the functions isWall(loc), isStart(loc) and isEnd (loc), all three have been written for you in lab14code.py. Download lab14code.py, rename the file, and complete the code. The function, escape (loc), tests whether there is a path out of the maze. If you would like a challenge, try implementing another function, escapePath(loc), which prints a path to an exit if one exist
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
