def cost_calculator(start_node: Node, end_node: Node): if start_node.__eq__(end_node): return 0 else: # moving horizontally or vertically if start_node.x == end_node.x or start_node.y == end_node.y: if start_node.border_node == True and end_node.border_node == True: # if both nodes are border nodes if (start_node.hits_count + end_node.hits_count ) < 4 and cells[cell_index_finder_for_2_diagonal_nodes( start_node, end_node)].high_risk == False: return 1.3 else: return 1000 # if at least one of the nodes is not a border node else: if (start_node.hits_count + end_node.hits_count) < 2: return 1 if (start_node.hits_count + end_node.hits_count) >= 2 and ( start_node.hits_count + end_node.hits_count ) < 6 and not ( cells[cells_finder_for_2_non_diagonal_nodes( start_node, end_node)[0]].high_risk == True and cells[cells_finder_for_2_non_diagonal_nodes( start_node, end_node)[1]].high_risk == True): return 1.3 else: return 1000 else: # moving diagonally if start_node.border_node == True or end_node.border_node == True: if (start_node.hits_count + end_node.hits_count) < 4: return 1.5 else: return 10000 else: # moving diagonally between two non-border nodes if cells[cell_index_finder_for_2_diagonal_nodes( start_node, end_node)].high_risk: return 10000 else: return 1.5
def __eq__(self, other): return Node.__eq__(self, other) and hasattr(other, "tag") and self.tag == other.tag
def __eq__(self, other): return Node.__eq__(self, other) and hasattr( other, "tag") and self.tag == other.tag