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