Question: need use python to do this Instructions For this lab, you will need to create three files: Labe4.py - file containing your solution to writing

need use python to do this Instructions For this lab, you willneed to create three files: Labe4.py - file containing your solution toneed use python to do this

Instructions For this lab, you will need to create three files: Labe4.py - file containing your solution to writing the solvelaze function as described in this writeup Stack.py - file containing your class definition of a Python Stack using Python Lists testFile.py - file containing pytest functions testing if your solution works as expected for your own mazes you'll create. Note: Gradescope's autograder requires you to submit your testfile.py in order for it to run your code (hopefully you're practicing TDD and use your tests to check correctness!) There will be no starter code for this assignment, but rather function descriptions and helper functions are given in the specification below. It's recommended that you organize your lab work in its own directory. This way all files for a lab are located in a single folder. Also, this will be casy to import various files into your code using the import / from technique shown in lecture. Solving a maze We can explore and solve a maze by utilizing a Stack data structure. The idea is given coordinates (xy positions), we can explore in certain directions until we reach dead ends or our goal. If we do reach a dead end, a Stack data structure can help us keep track of coordinates we've visited and allow us to "backtrack to a certain point. More context on this specific problem is covered in the book (See Recursion Chapter 4.6. Exploring a Maze). The book explains how this problem can be solved recursively, but in this lab we will not use recursion-rather we will do what recursion does for us and manually keep track of positions visited using our implementation of a Stack data structure. Representing a maze There can be several ways to represent a maze, but we will use anxm 2D List. An example below will help explain how the 2D List is being used as a maze: maze I'+',','','','','G'I. I'+',''','',''). The above example is a 6 x 6 maze. maze[x] lyl will represent a single item in the 2D List.naze[x] will contain a list and maze[x] lyl will contain a single clement (the yll item in the xh list). Since we're dealing with Python 2D Lists (a Python list where the clements are Python Lists), the indices of the maze coordinates start with 0. The top left position of the maze will be indexed atmazell (@) and the bottom right position of the maze will be indexed at naze (n-1] (n-1). If you would like to review Python 2D Lists, you may find the following CS 8 notes useful: https://ucsb-cs8.github.io/m19-wang/lectures/lect10/ Note: This layout is different than a traditional cartesian coordinate system. As we move right the y value increases, as we move left the y value decreases, as we move up the x value decreases, and as we move down the x value increases. The initial maze element can have one of three states '' - an empty space. This indicates the space can be moved into +- a wall. This indicates that you cannot move into this position G' - a goal. We are trying to see if a path exists to this position Traversing the maze Your program will need to traverse the 2D maze given a starting coordinate. As your program traverses the maze, you will need to keep track of the number of steps your algorithm takes and replace the clements in the maze as you move along with the number of steps value. (Lists (and 2D Lists) are mutable, so we should be able to change the maze structure as our algorithm progresses and it should keep these changes!). You may traverse the spaces horizontally and vertically (not diagonally). You must implement your traversal in following way When reaching a certain coordinate, you must check and move clockwise in the following order: North, then East, then South, then West You will always be given a starting coordinate. This will be the first step taken You will traverse the maze until you reach a goal ('6'). Once we reach the goal, our algorithm can stop (no need to keep traversing the maze) Using the maze provided above, let's assume your starting position is at naze (4)[4]. After your algorithm finshes, maze will have the following updates containing the number of steps: ('', 8, '+', 11, 12, 'G'), ("', 7, 9, 10, +''+'1. ["+', 6, '+','', 2, '+'1. ('', 5, 4, 3, 1, ''). This format is not too easy on the eyes, so we're providing a helper function below that you can use to print out the state of the maze in a more user-friendly way: def printMaze (maze): for row in rangellen(maze): for col in range(len (nazeal): print("*:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!