Skip to content

Instantly share code, notes, and snippets.

@fakemonk1
Created September 1, 2019 22:10
Show Gist options
  • Save fakemonk1/ec34e94e24ee68d2189b1557d98bd853 to your computer and use it in GitHub Desktop.
Save fakemonk1/ec34e94e24ee68d2189b1557d98bd853 to your computer and use it in GitHub Desktop.
def get_manhattan_heuristic(node, goal):
i, j = divmod(int(node), 8)
i_goal, j_goal = divmod(int(goal), 8)
i_delta = abs(i - i_goal)
j_delta = abs(j - j_goal)
manhattan_dist = i_delta + j_delta
return manhattan_dist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment