Assignment Search Framework
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
TileManhattanDistance Class Reference
Inheritance diagram for TileManhattanDistance:

Public Member Functions

 TileManhattanDistance (const TilePuzzleState &g, const TilePuzzleTransitions &ops)
 
virtual ~TileManhattanDistance ()
 
void setGoal (const TilePuzzleState &g, const TilePuzzleTransitions &ops)
 
- Public Member Functions inherited from Heuristic< TilePuzzleState >
 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...
 

Detailed Description

Manhattan distance calculator for tile puzzle states.

Constructor & Destructor Documentation

TileManhattanDistance::TileManhattanDistance ( const TilePuzzleState g,
const TilePuzzleTransitions ops 
)

Constructor that stores the given goal and tile move costs.

Parameters
gThe goal state.
opsThe transition function used to get the tile move costs.
TileManhattanDistance::~TileManhattanDistance ( )
virtual

Destructor for the tile Manhattan distance heuristic. Destructor is empty.

Member Function Documentation

double TileManhattanDistance::computeHValue ( const TilePuzzleState state) const
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.

Parameters
stateThe state whose heuristic value is to be calculated.
Returns
The heuristic value of the given state.

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.

Parameters
gThe new goal state.
opsThe transition function used to get the tile move costs.

Member Data Documentation

TilePuzzleState TileManhattanDistance::goal
protected

The goal state.

unsigned TileManhattanDistance::num_cols
protected

The number of columns in the puzzle.

unsigned TileManhattanDistance::num_rows
protected

The number of rows in the puzzle.

unsigned TileManhattanDistance::puzzle_size
protected

The total number of locations in the puzzle.

std::vector<std::vector<double> > TileManhattanDistance::tile_h_value
protected

The heuristic impact of the current tile in the current position. The first index (for the blank) is unused.

std::vector<double> TileManhattanDistance::tile_move_cost
protected

The cost of moving each tile.


The documentation for this class was generated from the following files: