def aStarManhattanHeuristic(self, val): if val == 0: f = lambda x: len(x) + heuristics.manhattanCost( x[-1][0], self.goal) h = lambda x: heuristics.manhattanCost(x[-1][0], self.goal) queue = dataStructure.PriorityQueue((f, h)) return self.aStarSearch(queue, val) elif val == 1: #used in computation of XY heuristic. f = lambda x: len(x) + heuristics.rowManhattan(x[-1][0], self.goal) h = lambda x: heuristics.rowManhattan(x[-1][0], self.goal) queue = dataStructure.PriorityQueue((f, h)) return self.aStarSearch(queue, val) else: #used in computation of XY heuristic. f = lambda x: len(x) + heuristics.colManhattan(x[-1][0], self.goal) h = lambda x: heuristics.colManhattan(x[-1][0], self.goal) queue = dataStructure.PriorityQueue((f, h)) return self.aStarSearch(queue, val)
def aStarXYHeuristic(self): f = lambda x: len(x) + heuristics.xyCostHeuristic(x[-1][0], self.goal) h = lambda x: heuristics.xyCostHeuristic(x[-1][0], self.goal) queue = dataStructure.PriorityQueue((f, h)) return self.aStarSearch(queue, 0)
def aStarLinearConflicts(self): f = lambda x: len(x) + heuristics.linearConflicts(x[-1][0], self.goal) h = lambda x: heuristics.linearConflicts(x[-1][0], self.goal) queue = dataStructure.PriorityQueue((f, h)) return self.aStarSearch(queue, 0)
def aStarNilssonHeuristic(self): f = lambda x: len(x) + heuristics.nilssonSequenceScore( x[-1][0], self.goal) h = lambda x: heuristics.nilssonSequenceScore(x[-1][0], self.goal) queue = dataStructure.PriorityQueue((f, h)) return self.aStarSearch(queue, 0)
def aStarMisplacedTiles(self): f = lambda x: len(x) + heuristics.misplacedTiles(x[-1][0], self.goal) h = lambda x: heuristics.misplacedTiles(x[-1][0], self.goal) queue = dataStructure.PriorityQueue((f, h)) return self.aStarSearch(queue, 0)