Question: Python Problem 6 - 2D Sliding Maze A maze can be described with a 2D array characters (or a list of lists). A space describes
Python


Problem 6 - 2D Sliding Maze A maze can be described with a 2D array characters (or a list of lists). A space "describes the absence of an obstacle while a hash '#' is used for an obstacle. A sliding maze is one where in addition to normal the obstacles in the maze, there are also moving obstacles that always surrounds the player position. The player can either make a step in 4 directions (up, down, left, right) or shift all the surrounding obstacles either clockwise, or counterclockwise. Moving obstacles are described using @ Write a function, sliding_maze (maze, k) that takes a maze and k (an integer value between 1 and 3) which represents the number of moving obstacles surrounding the player filled up from top in clockwise fashion (top, right, bottom, left). Noting that moving obstacles cannot overlap with normal obstacles. The return of the function should be True if there exists any passable path from the lower bottom corner to the top right corner of the maze. Otherwise, False x is for player position, o is used for non obstacle instead of space for clarity. Example 1 - solvable: initial maze state, k = 1: maze = "" #oo Coo 111111 sliding_maze (maze, 1) # returns: True step 1 (move right): 111111 #oo o@o OXO step 2 (move right): 111111 #oo oo@ step 3 (shift left): #00 000 o@x 111111 step 4 (move up): #00 o@x 000 111111 step 5 (move up) Victory!: #@x 000 000 111111 Example 2 - unsolvable: initial maze state, k = 3: maze = "" #0000 @o000 x@#00 111111 sliding_maze (maze, 3) #returns False # possibility 1 step 1 (shift right): 111111 #oooo 00000 x@#00 step 2 (move up) : 111111 #0000 X@ooo @o#00 111111 Deadlock, cannot shift left or right as one of the moving obstacles would hit the obstacle # possibility 2 step 1 (shift right): #0000 00000 x@#00 step 2 (shift right): 111111 #oooo @oooo xo#00 step 3 (move right): 111111 #oooo o@ooo @x#00 111111 step 4 (move up): #@000 @xooo o@#00 111111 Deadlock, cannot shift left or right as one of the moving obstacles would hit the eithr ti
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
