#"parent" will be added as a variable of each nodeclass finder(self): #just in case the variables need to be global def __init__(self): self.open = [] self.closed = [] self.current = startnode #startnode is determined by closest to AI self.path = []def calc_pathcost(end,start): #determines the cost of the pre-determined path between two points pathcost = 0 cur_node = end while cur_node != start: pathcost += dist(cur_node, cur_node.parent) #adds all the distances following the path so far cur_node = cur_node.parent return pathcostdef shortcut(node): for neighbor in node.neighbors: if neighbor is in f.closed: if dist(node,neighbor) < calc_pathcost(node,neighbor): node.parent = neighborf = finder()while f.current != endnode: for neighbor in f.current.neighbors: if neighbor is not in the closed list: f.open.append(neighbor) if there are no neighbors not in the closed list: f.current = f.current.parent for open_neighbor in f.open: Bestnode = the neighbor with the lowest f cost f.open.pop(Bestnode) f.closed.append(Bestnode) Bestnode.parent = f.current shortcut(Bestnode) f.current = Bestnodeif f.current == endnode: while f.current != startnode: f.path.append(f.current) f.current = f.current.parent