From 45f4f3b707b1e86b3749ceb09ec781e7b0e48fc5 Mon Sep 17 00:00:00 2001 From: cdez Date: Sun, 16 Feb 2025 00:02:27 -0700 Subject: [PATCH] Finished the RouteFinding Pt 0 assignment. --- RouteFinding/05_tests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/RouteFinding/05_tests.py b/RouteFinding/05_tests.py index d3febba..5fbc049 100644 --- a/RouteFinding/05_tests.py +++ b/RouteFinding/05_tests.py @@ -1,5 +1,15 @@ # Define Searcher, hSLD, SearchNode. import DRDViz +import math + +def hSLD(node, search): + # take the node value in + # find the node value coordinates + coords = search.nodeLocs[node] + goalCoords = search.nodeLocs[search.endNode] + # calculate the distance between the two points + distance = math.sqrt((abs(int(coords[0]) - int(goalCoords[0])))**2 + abs(int(coords[1]) - int(goalCoords[1]))**2) + return distance class SearchNode: def __init__(self, label, pathcost):