astar_temp #19

Merged
s481825 merged 12 commits from astar_temp into master 2024-05-10 17:34:48 +02:00
Showing only changes of commit d150e9c21d - Show all commits

View File

@ -173,7 +173,7 @@ def succ3A(state):
def heuristic2(state, goal):
# Oblicz odległość Manhattanowską między aktualnym stanem a celem
manhattan_distance = (abs(state['x'] - goal[0]) + abs(state['y'] - goal[1])) * 5.5
manhattan_distance = (abs(state['x'] - goal[0]) + abs(state['y'] - goal[1])) * 2.5
return manhattan_distance
@ -255,4 +255,30 @@ def A_star2(istate, pole, goalTreasure):
if event.type == pygame.QUIT:
quit()
return False
return False
"""
TO TEST SPEED OF ASTAR
test_speed = False
if test_speed:
time1 = 0
time2 = 0
cost1 = 0
cost2 = 0
for i in range(500):
print(i)
start = time.time()
aStarRoot, cost_list, total_cost = AStar.A_star({'x': 0, 'y': 0, 'direction': "E"}, pole, goalTreasure)
end = time.time()
time1 += end - start
cost1 += total_cost
start = time.time()
aStarRoot2, cost_list, total_cost = AStar.A_star2({'x': 0, 'y': 0, 'direction': "E"}, pole, goalTreasure)
end = time.time()
time2 += end - start
cost2 += total_cost
print(time1, time2)
print(float(cost1 / 1000), float(cost2 / 1000))
"""