Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Populate the priority queue with nodes and their cost.
@type graph: Map @param graph: Graph to get moves from to populate queue @type queue: Queue @param queue: Queue with nodes being added to it with the cost @type parent: AStarNode @param parent: Parent for the nodes that will be created """ # get possible moves
# put into queue all the moves possible # make move and get copy
# calculate heuristic for this move that was made
# create node
# put the node in priority queue
""" Get the best path to solve the given graph.
@rtype: [Move] @return: Array of moves which represent the path found to solve the puzzle """ # make sure the board isn't already solved
# make sure the given heuristic is a function that can be called
# initialize data structures for A*
# populate queue with moves and nodes
# get the next position from the queue
# make sure this position hasn't been explored # check if the board is solved
# if not solved, add to explored and populate queue
|