astar #4
8
board
8
board
@ -158,10 +158,10 @@ def kb_listen(objectArray, gridLength):
|
||||
|
||||
|
||||
#moje
|
||||
def manhattan(field1, field2):#nasze punktyNOWE
|
||||
tuple1 = zip(field1, field2)#łączymy xpos1 z xpos2 i ypos1 z ypos2
|
||||
for i, j in tuple1:
|
||||
distance = sum(abs(i - j))#dodajemy wartości bezwzględne różnic x i y
|
||||
def manhattan(node1, node2):
|
||||
x1, y1 = node1.state[0], node1.state[1]
|
||||
x2, y2 = node2.state[0], node2.state[1]
|
||||
distance = abs(x1 - x2) + abs(y1 - y2)
|
||||
return distance
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user