Assignment Search Framework
|
Public Member Functions | |
TilePuzzleTransitions (unsigned rows, unsigned cols, TileCostType cost=TileCostType::unit) | |
TilePuzzleTransitions (unsigned rows, unsigned cols, const std::vector< double > &tile_costs) | |
virtual | ~TilePuzzleTransitions () |
virtual bool | isApplicable (const TilePuzzleState &state, const BlankSlide &action) const |
virtual double | getActionCost (const TilePuzzleState &state, const BlankSlide &action) const |
virtual void | applyAction (TilePuzzleState &state, const BlankSlide &action) const |
virtual void | getActions (const TilePuzzleState &state, std::vector< BlankSlide > &actions) const |
virtual bool | isInvertible (const TilePuzzleState &state, const BlankSlide &action) const |
virtual BlankSlide | getInverse (const TilePuzzleState &state, const BlankSlide &action) const |
BlankSlide | getDummyAction () const |
bool | isDummyAction (const BlankSlide &action) const |
void | setStandardTileCostType (const TileCostType cost_type) |
void | setCustomTileCostType (const std::vector< double > &tile_costs) |
void | setProperties (unsigned rows, unsigned cols, TileCostType cost_type=TileCostType::unit) |
void | setProperties (unsigned rows, unsigned cols, const std::vector< double > &tile_costs) |
double | getTileMoveCost (unsigned tile) const |
![]() | |
TransitionSystem () | |
virtual | ~TransitionSystem () |
virtual bool | isChildState (const TilePuzzleState &parent, const TilePuzzleState &child) const |
virtual void | getSuccessors (const TilePuzzleState &state, std::vector< TilePuzzleState > &children) const |
bool | applyActionSequence (TilePuzzleState &state, const std::vector< BlankSlide > &actions) const |
bool | isApplicableSequence (const TilePuzzleState &state, const std::vector< BlankSlide > &actions) const |
Protected Member Functions | |
void | setActionList (unsigned rows, unsigned cols) |
bool | isApplicableInLocation (const BlankSlide &action, unsigned blank_loc) const |
unsigned | getMovingTile (const TilePuzzleState &state, const BlankSlide &action) const |
Protected Attributes | |
unsigned | num_rows |
Number of rows in the puzzle. More... | |
unsigned | num_cols |
Number of columns in the puzzle. More... | |
std::vector< std::vector < BlankSlide > > | loc_actions |
Caches the actions applicable for each blank location. More... | |
std::vector< BlankSlide > | ops_in_order |
An ordering of all the possible actions. More... | |
std::vector< double > | tile_move_cost |
Caches the cost of moving each tile. More... | |
Defines the transition system for the sliding tile puzzle.
Add operator ordering options.
Check what the default operator ordering should be.
TilePuzzleTransitions::TilePuzzleTransitions | ( | unsigned | rows, |
unsigned | cols, | ||
TileCostType | cost = TileCostType::unit |
||
) |
Builds a tile puzzle transition system with the given number of rows, columns, and cost type.
rows | The number of rows in the puzzle. |
cols | The number of columns in the puzzle. |
cost | The action cost type. |
TilePuzzleTransitions::TilePuzzleTransitions | ( | unsigned | rows, |
unsigned | cols, | ||
const std::vector< double > & | tile_costs | ||
) |
Builds a tile puzzle transition system with the given number of rows, columns, and custom tile cost type.
The custom tile cost type is defined as list of numbers, where the value at index i is the cost of moving tile i. The value at index 0 is ignored.
rows | The number of rows in the puzzle. |
cols | The number of columns in the puzzle. |
tile_costs | A list defining the custom tile cost. |
|
virtual |
Destructor for tile puzzle transition system. Destructor is empty.
|
virtual |
Applies the given action to the given state.
Assumes the given action is applicable in the given state.
state | The state to update. |
action | The action to apply. |
Implements TransitionSystem< TilePuzzleState, BlankSlide >.
|
virtual |
Returns the cost of applying the given action in the given state.
Assumes the action is actually applicable in that state.
state | The state to apply the action in. |
action | The action to apply. |
Implements TransitionSystem< TilePuzzleState, BlankSlide >.
|
virtual |
Gets the actions applicable in a given state and appends them to the given list.
state | The state to generate actions in. |
actions | The list of actions to append to. |
Implements TransitionSystem< TilePuzzleState, BlankSlide >.
|
virtual |
Returns the dummy action for this domain.
The dummy action should never actually be applicable and is not invertible.
Implements TransitionSystem< TilePuzzleState, BlankSlide >.
|
virtual |
Returns the inverse of a given action.
If no inverse exists, returns the dummy action.
state | The state the action is being applied in. |
action | The action to invert. |
Reimplemented from TransitionSystem< TilePuzzleState, BlankSlide >.
|
protected |
Gets the identity of the tile being moved by the given action.
Assumes the action is applicable in the given state.
state | The state in which the move is being applied. |
action | The action to apply. |
double TilePuzzleTransitions::getTileMoveCost | ( | unsigned | tile | ) | const |
Returns the cost of moving the specified tile.
tile | The tile to move. |
|
virtual |
Checks if the action is applicable in the given state.
state | The state in the domain. |
action | The action to test for applicability. |
Reimplemented from TransitionSystem< TilePuzzleState, BlankSlide >.
|
protected |
Checks if the given action is applicable given the current location of the blank.
action | The action to check. |
blank_loc | The location of the blank. |
|
virtual |
Checks if the given action is the dummy action for this domain.
action | The action to check. |
Implements TransitionSystem< TilePuzzleState, BlankSlide >.
|
virtual |
Checks if the given action is invertible in the given state.
Assumes the action is either the dummy action, or is applicable in the given state.
state | The state the action is being applied in. |
action | The action to check. |
Reimplemented from TransitionSystem< TilePuzzleState, BlankSlide >.
|
protected |
Caches the set of actions applicable for each location of the blank.
Actions are generated according to the operator ordering currently in use.
rows | The number of rows in the puzzle. |
cols | The number of columns in the puzzle. |
void TilePuzzleTransitions::setCustomTileCostType | ( | const std::vector< double > & | tile_costs | ) |
Sets the tile_costs to a custom cost type.
The function takes in a list of double values, such that the value at index i is the cost of moving tile i.
tile_costs | A list of the tile costs. |
void TilePuzzleTransitions::setProperties | ( | unsigned | rows, |
unsigned | cols, | ||
TileCostType | cost_type = TileCostType::unit |
||
) |
Sets the properties of the problem, including a cost type selected from the standard options.
rows | The number of rows. |
cols | The number of columns. |
cost_type | The action cost type. |
void TilePuzzleTransitions::setProperties | ( | unsigned | rows, |
unsigned | cols, | ||
const std::vector< double > & | tile_costs | ||
) |
Sets the properties of the problem, including a custom tile cost type.
rows | The number of rows. |
cols | The number of columns. |
tile_costs | A list of numbers defining the cost of moving each tile. |
void TilePuzzleTransitions::setStandardTileCostType | ( | const TileCostType | cost_type | ) |
Sets the tile costs to one of the standard types.
cost_type | The cost type for the transitions. |
|
protected |
Caches the actions applicable for each blank location.
|
protected |
Number of columns in the puzzle.
|
protected |
Number of rows in the puzzle.
|
protected |
An ordering of all the possible actions.
|
protected |
Caches the cost of moving each tile.