Esempio n. 1
0
def pathFind(start, end):
	if (ValidatePoint.validate(start) > 0 and ValidatePoint.validate(end) > 0):
		start = ValidatePoint.getPoint(start)
		start[5] = ValidatePoint.getChildren(start, [])
		return calcPath(start,end)
	else:
		if (ValidatePoint.validate(start) < 0):
			raise Exception("Cannot validate start point.")
		else:
			raise Exception("Cannot validate end point.")
Esempio n. 2
0
def calcPath(start, end):
	start[3] = 0
	start[4] = ValidatePoint.calcDistance(start,end)
	start.append(0)
	curNode = start
	leaves = [curNode]
	expandedNodes = []
	while not ValidatePoint.isEqual(curNode, end):
		leaves.remove(curNode)
		expandedNodes.append(curNode)
		curNode[5] = ValidatePoint.getChildren(curNode, expandedNodes)
		for node in curNode[5]:
			node[3] = curNode[3] + ValidatePoint.calcDistance(node, curNode)
			node[4] = ValidatePoint.calcDistance(node, end)
			node.append(curNode)
			leaves.append(node)
		curNode = findLeastCost(leaves)
	return backwardTraverse(curNode, start)