Question: Say you are traversing a maze using an AI - based robot. For this, you are to develop a method, namely, location ( row ,

Say you are traversing a maze using an AI-based robot. For this, you are to develop a
method, namely, location(row,col), which returns the next location based on the
neighbors that are adjacent to the current location of the robot. We will simplify all the
movements of the robot in several requirements:
a. The robot is to move from the top-left corner to the bottom-right corner in a 2D
array (this means you only need to check two neighbors that are to be considered
for moving: the element below the given element and the element to the right to
the given element, if they exist).
b. If both neighbors exist, the location of the neighbor with the smaller value is
returned. Assume that two neighbors will always have different values.
c. If only one neighbor exists (say you reached the bottom-most row or the rightmost column), the location of the existing neighbor is returned.
Based on the above-mentioned rules, write your method, location(row, col), that
repeatedly returns the trajectory of the robot.

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 Programming Questions!