Concept explainers
can you help me with this code because I am struggling:
question that I need help with:
it will be
investigate the problem of navigation on a two-dimensional grid with obstacles. The goal is to produce the shortest path between a provided pair of points, taking care to maneuver around the obstacles as needed. Path length is measured in Euclidean distance. Valid directions of movement include up, down, left, right, up-left, up-right, down-left, and down-right.
Your task is to write a function find_path(start, goal, scene) which returns the shortest path from the start point to the goal point that avoids traveling through the obstacles in the grid. For this problem, points will be represented as two-element tuples of the form (row, column), and scenes will be represented as two-dimensional lists of Boolean values, with False values corresponding empty spaces and True values corresponding to obstacles. Your output should be the list of points in the path, and should explicitly include both the start point and the goal point. Your implementation should consist of an A* search using the straight-line Euclidean distance heuristic. If multiple optimal solutions exist, any of them may be returned. If no optimal solutions exist, or if the start point or goal point lies on an obstacle, you should return the sentinal value None.
>>> scene = [[False, False, False],
... [False, True , False],
... [False, False, False]]
>>> find_path((0, 0), (2, 1), scene)
[(0, 0), (1, 0), (2, 1)]
>>> scene = [[False, True, False],
... [False, True, False],
... [False, True, False]]
>>> print find_path((0, 0), (0, 2), scene)
None
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
- Hello. Please answer the attached Algorithms question and its two parts correctly. You don't have to give a long explanation for each part. *If you answer the question and its parts correctly, I will give you a thumbs up. Thanks.arrow_forwardCan you help me with this code becuase I only need help with one of the parts. I have attached my code below and task the needs to answered but you have to use my code and the variables which I have provided in the photo. question that i need help with: the Eight Puzzle consists of a 3 x 3 board of sliding tiles with a single empty space. For each configuration, the only possible moves are to swap the empty tile with one of its neighboring tiles. The goal state for the puzzle consists of tiles 1-3 in the top row, tiles 4-6 in the middle row, and tiles 7 and 8 in the bottom row, with the empty space in the lower-right corner.you will develop two solvers for a generalized version of the Eight Puzzle, in which the board can have any number of rows and columns. A natural representation for this puzzle is a two-dimensional list of integer values between 0 and r · c -1 (inclusive), where r and c are the number of rows and columns in the board, respectively. In this problem, we will adhere…arrow_forward