Assignment Search Framework
|
Public Member Functions | |
TileManhattanDistance (const TilePuzzleState &g, const TilePuzzleTransitions &ops) | |
virtual | ~TileManhattanDistance () |
void | setGoal (const TilePuzzleState &g, const TilePuzzleTransitions &ops) |
![]() | |
Heuristic () | |
virtual | ~Heuristic () |
virtual void | prepareToCompute () |
double | getHValue (const TilePuzzleState &state) |
double | getLastHValue () const |
bool | isHValueStored () const |
Protected Member Functions | |
virtual double | computeHValue (const TilePuzzleState &state) const |
Protected Attributes | |
TilePuzzleState | goal |
The goal state. More... | |
unsigned | num_rows |
The number of rows in the puzzle. More... | |
unsigned | num_cols |
The number of columns in the puzzle. More... | |
unsigned | puzzle_size |
The total number of locations in the puzzle. More... | |
std::vector< std::vector < double > > | tile_h_value |
The heuristic impact of the current tile in the current position. The first index (for the blank) is unused. More... | |
std::vector< double > | tile_move_cost |
The cost of moving each tile. More... | |
Manhattan distance calculator for tile puzzle states.
TileManhattanDistance::TileManhattanDistance | ( | const TilePuzzleState & | g, |
const TilePuzzleTransitions & | ops | ||
) |
Constructor that stores the given goal and tile move costs.
g | The goal state. |
ops | The transition function used to get the tile move costs. |
|
virtual |
Destructor for the tile Manhattan distance heuristic. Destructor is empty.
|
protectedvirtual |
Calculates the heuristic value of the given state. Does not store the heuristic value.
If the heuristic value is negative, the heuristic function is indicating unsolvability.
This is the main function to be overloaded.
state | The state whose heuristic value is to be calculated. |
Implements Heuristic< TilePuzzleState >.
void TileManhattanDistance::setGoal | ( | const TilePuzzleState & | g, |
const TilePuzzleTransitions & | ops | ||
) |
Sets the goal to the given state and the tile move costs using the given transition function.
g | The new goal state. |
ops | The transition function used to get the tile move costs. |
|
protected |
The goal state.
|
protected |
The number of columns in the puzzle.
|
protected |
The number of rows in the puzzle.
|
protected |
The total number of locations in the puzzle.
|
protected |
The heuristic impact of the current tile in the current position. The first index (for the blank) is unused.
|
protected |
The cost of moving each tile.