Menu

[Solved]-Python Cpts 121 131 Learned Write Recursive Function Solve Solution Maze Maze Represented Q37222485

In Python

In CptS 121/131 you learned how to write a recursive function tosolve a solution through a maze. The maze was represented as a 2dimensional array of cells. Each cell was either open or an “X”,which represented a wall. The solution you derived was abacktracking algorithm that tried many different paths (probablysomething like right, down, left, up). If the algorithm hit a deadend it would back track, trying a different path. The solution ofthe backtracking algorithm was not optimal. Using graphs, we canfind the shortest path from the start point to the end point. Wecan represent a maze as a graph by adding a vertex for the start,the end, each decision point (i.e. an intersection), and a vertexfor each dead end. The edges represent connections in the mazebetween locations (our graph vertices). Each edge will beunweighted, meaning we are ignoring the length of the connection interms of the number of cells in the maze. Define a 16x16semi-difficult maze. Include your maze as an image in yournotebook, code it up as a 2D list, or visualize it usingmatplotlib. Construct a graph from your maze. Find the shortestpath from the start vertex to the end vertex using a breadth-firstsearch. The shortest path will represent the fewest number ofvertices (decision points) in the graph, not the shortest distancein terms of the number of cells along the path. Display theshortest path and the number of decision points in the path.

Expert Answer


Answer to In Python In CptS 121/131 you learned how to write a recursive function to solve a solution through a maze. The maze was… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *