Finished the RouteFinding Pt 0 assignment.
This commit is contained in:
parent
54477a4266
commit
45f4f3b707
1 changed files with 10 additions and 0 deletions
|
|
@ -1,5 +1,15 @@
|
||||||
# Define Searcher, hSLD, SearchNode.
|
# Define Searcher, hSLD, SearchNode.
|
||||||
import DRDViz
|
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:
|
class SearchNode:
|
||||||
def __init__(self, label, pathcost):
|
def __init__(self, label, pathcost):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue