Question
Hi, I have a programing problem of finding monotonic heuristics (in python). I have this function which takes two points a and b in the
Hi,
I have a programing problem of finding monotonic heuristics (in python).
I have this function which takes two points a and b in the n-dimensional space and returns the d-dimensional point r such that r_i = | a_i - b_i | for i = 1...d
def distance_in_each_coordinate(x, y):
res = [ abs(a-b) for (a,b) in zip(x, y) ]
return res
Then I have the following function, which receives coordinates of two grid points and return the estimated distance between them.
def grid_2D_heuristic(current, destination): # the grid is a classic 2D grid
dst_per_coor = distance_in_each_coordinate(current, destination)
return sum(dst_per_coor)
And similarly I would like to know how to calculate the distance in a 2D grid, where the edges correspond exactly to the movement of the rook on the chessboard where the movement distance is limited to 8 cells (for example, it contains {(0,0), (0,8)} and {(0,0), (-8,0)} but it does not include {(0,0), (9,0)})
def grid_rook_2D_heuristic(current, destination):
return 'WHAT DO I RETURN HERE?'
Could you please help me find the monotonic heuristic in a 2D grid with the rook movement?
Thank you! <3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started