Dodanie funkcji h(start, goal)
This commit is contained in:
parent
1e265ec281
commit
32c80c0c0e
6
agent.py
6
agent.py
@ -2,6 +2,7 @@ from warehouse import Coordinates, Tile, Pack
|
|||||||
from attributes import PackStatus, TURN_LEFT_DIRECTIONS, TURN_RIGHT_DIRECTIONS
|
from attributes import PackStatus, TURN_LEFT_DIRECTIONS, TURN_RIGHT_DIRECTIONS
|
||||||
from queue import PriorityQueue
|
from queue import PriorityQueue
|
||||||
from pathfinder import Node
|
from pathfinder import Node
|
||||||
|
from math import sqrt
|
||||||
|
|
||||||
class Agent:
|
class Agent:
|
||||||
def __init__(self, start_x, start_y, assigned_warehouse, radius=5):
|
def __init__(self, start_x, start_y, assigned_warehouse, radius=5):
|
||||||
@ -141,6 +142,11 @@ class Agent:
|
|||||||
# tu chodzi o to że zmieni się akcja i rodzić, ale stan nie
|
# tu chodzi o to że zmieni się akcja i rodzić, ale stan nie
|
||||||
# zamień w fringe stary węzeł o stanie x[1] z węzłem x
|
# zamień w fringe stary węzeł o stanie x[1] z węzłem x
|
||||||
|
|
||||||
|
def h(self, start, goal):
|
||||||
|
diff_x = pow(goal.x_position - start.x_position,2)
|
||||||
|
diff_y = pow(goal.y_position - start.y_position, 2)
|
||||||
|
return round(sqrt(diff_x+diff_y), 3)
|
||||||
|
|
||||||
def get_succ(self, elem):
|
def get_succ(self, elem):
|
||||||
move = self.move
|
move = self.move
|
||||||
turn_left = self.turn_left
|
turn_left = self.turn_left
|
||||||
|
Loading…
Reference in New Issue
Block a user