a star1.0

This commit is contained in:
aliaksei-kudravets 2022-05-06 12:27:18 +02:00
parent 37375d4f1d
commit 29a11547f4
2 changed files with 5 additions and 5 deletions

View File

@ -1,7 +1,7 @@
from data_structures.heap import Heap
from path_search_algorthms import a_star_utils as utils
def search_path(start_x: int, start_y: int, agent_rotation: utils.Rotation, target_x: int, target_y: int, array: list[list[int]]) -> list[str]:
def search_path(start_x: int, start_y: int, agent_rotation: utils.Rotation, target_x: int, target_y: int, array):
start_node = utils.Node(start_x, start_y, agent_rotation)
target_node = utils.Node(target_x, target_y, utils.Rotation.NONE)
@ -84,7 +84,7 @@ def search_path(start_x: int, start_y: int, agent_rotation: utils.Rotation, targ
# if(neighbour not in search_list):
# search_list.append(neighbour)
def trace_path(end_node: utils.Node) -> list[str]:
def trace_path(end_node: utils.Node):
path = []
node = end_node

View File

@ -26,7 +26,7 @@ class Node:
def f_cost(self):
return self.g_cost + self.h_cost
def get_neighbours(node: 'Node', searched_list: list['Node'], array: list[list[int]]) -> list['Node']:
def get_neighbours(node, searched_list, array):
neighbours = []
for offset_x in range (-1, 2):
for offset_y in range (-1, 2):
@ -45,7 +45,7 @@ def get_neighbours(node: 'Node', searched_list: list['Node'], array: list[list[i
# move cost schema:
# - move from tile to tile: 10
# - add extra 10 (1 rotation) if it exists
def get_h_cost(start_node: Node, target_node: Node) -> int:
def get_h_cost(start_node: Node, target_node: Node):
distance_x = abs(start_node.x - target_node.x)
distance_y = abs(start_node.y - target_node.y)
cost = (distance_x + distance_y) * 10
@ -69,7 +69,7 @@ def get_neighbour_cost(start_node: Node, target_node: Node) -> int:
return 30
# translate rotation change to move
def get_move(start_node: Node, target_node: Node) -> list[str]:
def get_move(start_node: Node, target_node: Node):
rotate_change = get_rotate_change(start_node.rotation, target_node.rotation)
if (rotate_change == 0):
return ["forward"]