From 1dca71a2aa63f2c5b3ea3e389dd25a4ff4f8685d Mon Sep 17 00:00:00 2001 From: Yan Figueiredo Date: Sun, 14 Nov 2021 19:49:32 -0300 Subject: [PATCH] astar heuristic --- search/algorithms/heuristic.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/search/algorithms/heuristic.py b/search/algorithms/heuristic.py index c23bd61..5086c32 100644 --- a/search/algorithms/heuristic.py +++ b/search/algorithms/heuristic.py @@ -11,16 +11,9 @@ def heuristic_manhattan(state): return res -def heuristic_manhattan_2(state): - res = 0 - goal = state.get_goal() - - for i in range(state.size * state.size): - x, y = state.table(i) - x_t, y_t = state.table( goal.index( state.state[i] ) ) - res += abs(x - x_t) + abs(y - y_t) - return state.depth + res +def heuristic_astar(state): + return state.depth + heuristic_manhattan(state) def heuristic_default(state):