Skip to content

Instantly share code, notes, and snippets.

@sofoklis
Created February 21, 2013 22:13
Show Gist options
  • Save sofoklis/5008832 to your computer and use it in GitHub Desktop.
Save sofoklis/5008832 to your computer and use it in GitHub Desktop.
switching heuristic in Eight puzzle
// Creating a different solution with exactly the same code but a different
// ordering in my queue, so one can easily add solutions with better
// heuristic functions
def bestSolution(ordering: Ordering[(State, List[Move])]) =
aStarSearch(PriorityQueue((initialState, List[Move]()))(ordering), Set())
lazy val bestSolutionManhatan: Option[List[Move]] =
bestSolution(manhatanOrdering)
lazy val bestSolutionMisplaced: Option[List[Move]] =
bestSolution(misplacedOrdering)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment