from github
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import math
|
||||
import sys
|
||||
|
||||
|
||||
class Node:
|
||||
def __init__(self, x, y):
|
||||
self.x: int = x
|
||||
self.y: int = y
|
||||
self.h_cost = self.p_cost = self.g_cost = sys.float_info.max
|
||||
self.parent = None
|
||||
|
||||
# Berechnet alle Kosten (Entfernungen) für den Pathfinding-Algorithmus der Geister.
|
||||
def calculate_cost(self, end_node):
|
||||
self.h_cost = math.sqrt(math.pow(end_node.x - self.x, 2) + math.pow(end_node.y - self.y, 2))
|
||||
self.p_cost = self.parent.p_cost + 1
|
||||
self.g_cost = self.h_cost + self.p_cost
|
||||
|
||||
def __str__(self):
|
||||
return str(self.x) + " " + str(self.y)
|
||||
Reference in New Issue
Block a user