Skip to content

Commit

Permalink
astar heuristic
Browse files Browse the repository at this point in the history
  • Loading branch information
yaansz committed Nov 14, 2021
1 parent 5dd0d55 commit 1dca71a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions search/algorithms/heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1dca71a

Please sign in to comment.