Search code examples
searchartificial-intelligenceheuristics

Heuristic function for solving weighted 15 puzzle


I am looking for a heuristic function to solve a "weighted 15 puzzle"
problem. It's the same as "15 puzzle" only i'm looking for the minimal
path to 1-15 (Link) when each "switch" costs as the piece we're moving.


Solution

  • Heuristic evaluation function for a weighted 15 puzzle:

    i - The element.  
    MD(i) - Manhattan distance to the destination from the position of (i).
    

    enter image description here