Assignment Search Framework
|
Public Member Functions | |
MapPathfindingTransitions (bool four_dirs=true) | |
MapPathfindingTransitions (std::string file_name, bool four_dirs=true) | |
virtual | ~MapPathfindingTransitions () |
virtual bool | isApplicable (const MapLocation &state, const MapDir &action) const |
virtual double | getActionCost (const MapLocation &state, const MapDir &action) const |
virtual void | applyAction (MapLocation &state, const MapDir &action) const |
virtual void | getActions (const MapLocation &state, std::vector< MapDir > &actions) const |
virtual bool | isInvertible (const MapLocation &state, const MapDir &action) const |
virtual MapDir | getInverse (const MapLocation &state, const MapDir &action) const |
MapDir | getDummyAction () const |
bool | isDummyAction (const MapDir &action) const |
bool | loadMap (std::string file_name) |
unsigned | getMapWidth () const |
unsigned | getMapHeight () const |
void | set4Connected () |
void | set8Connected () |
bool | setDiagonalCost (double d_cost) |
bool | is4Connected () const |
bool | is8Connected () const |
void | clearMap () |
![]() | |
TransitionSystem () | |
virtual | ~TransitionSystem () |
virtual bool | isChildState (const MapLocation &parent, const MapLocation &child) const |
virtual void | getSuccessors (const MapLocation &state, std::vector< MapLocation > &children) const |
bool | applyActionSequence (MapLocation &state, const std::vector< MapDir > &actions) const |
bool | isApplicableSequence (const MapLocation &state, const std::vector< MapDir > &actions) const |
Protected Member Functions | |
bool | canNorth (const MapLocation &state) const |
bool | canEast (const MapLocation &state) const |
bool | canSouth (const MapLocation &state) const |
bool | canWest (const MapLocation &state) const |
bool | isNEEmpty (const MapLocation &state) const |
bool | isSEEmpty (const MapLocation &state) const |
bool | isSWEmpty (const MapLocation &state) const |
bool | isNWEmpty (const MapLocation &state) const |
Protected Attributes | |
unsigned | map_width |
The map width. More... | |
unsigned | map_height |
The map height. More... | |
bool | four_connected |
If the map is 4-connected or 8-connected. More... | |
double | diag_cost |
The cost of a diagonal move. More... | |
std::vector< std::vector< bool > > | grid_empty |
Indexed by location, indicates if it is empty or an obstacle. More... | |
Defines the transitions for map pathfinding.
Currently sets the origin (0,0) as the upper left corner in keeping with benchmark standard. Locations are either empty or have an obstacle. If the transition system is set as 4-connected, then movement is only possible in the 4 cardinal directions (North, East, South, and West). If it is not 4-connected, it is 8-connected, which means it is possible to move in the 4 cardinal directions as well as Northeast, Southeast, Southwest, and Northwest.
Set the bottom left corner to be (0, 0)?
Allow for different terrain types.
Allow for different terrain heights.
MapPathfindingTransitions::MapPathfindingTransitions | ( | bool | four_dirs = true | ) |
A constructor for a map pathfinding transition system. Constructs a completely empty map.
four_dirs | Whether the system is 4-connected. Set as true by default. |
MapPathfindingTransitions::MapPathfindingTransitions | ( | std::string | file_name, |
bool | four_dirs = true |
||
) |
A constructor for a map pathfinding transition system. Loads in the map from the file from the given file name.
file_name | The name of the file to load the map from. |
four_dirs | Whether the system is 4-connected. Set as true by default. |
|
virtual |
A destructor for a map pathfinding transition system. Does nothing.
|
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< MapLocation, MapDir >.
|
protected |
Returns true of it is possible to move east from the current location.
state | The state currently located at. |
|
protected |
Returns true of it is possible to move north from the current location.
state | The state currently located at. |
|
protected |
Returns true of it is possible to move south from the current location.
state | The state currently located at. |
|
protected |
Returns true of it is possible to move west from the current location.
state | The state currently located at. |
void MapPathfindingTransitions::clearMap | ( | ) |
Clears the current map.
|
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< MapLocation, MapDir >.
|
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< MapLocation, MapDir >.
|
virtual |
Returns the dummy action for this domain.
The dummy action should never actually be applicable and is not invertible.
Implements TransitionSystem< MapLocation, MapDir >.
|
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< MapLocation, MapDir >.
unsigned MapPathfindingTransitions::getMapHeight | ( | ) | const |
Returns the height of the map.
unsigned MapPathfindingTransitions::getMapWidth | ( | ) | const |
Returns the width of the map.
bool MapPathfindingTransitions::is4Connected | ( | ) | const |
Checks if the given map is 4-connected.
bool MapPathfindingTransitions::is8Connected | ( | ) | const |
Checks if the given map is 8-connected.
|
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< MapLocation, MapDir >.
|
virtual |
Checks if the given action is the dummy action for this domain.
action | The action to check. |
Implements TransitionSystem< MapLocation, MapDir >.
|
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< MapLocation, MapDir >.
|
protected |
Checks if the location northeast of the given location is empty.
state | The state currently located at. |
|
protected |
Checks if the location northwest of the given location is empty.
state | The state currently located at. |
|
protected |
Checks if the location southeast of the given location is empty.
state | The state currently located at. |
|
protected |
Checks if the location southwest of the given location is empty.
state | The state currently located at. |
bool MapPathfindingTransitions::loadMap | ( | std::string | file_name | ) |
Loads the map from the file with the given file name.
If reading fails, the map is cleared and false is returned.
The file format is as follows. There must be a line that contains only the word "map", which indicates that the remainder of the file is a representation of the map. An empty location is indicated by any of the symbols '.' 'G' or 'S'. An obstacle is indicated by any of the symbols '@', 'O', 'W', or 'T.' Any other symbol will cause an error.
Prior to the line that says map, there must be at least two lines, one of which is of the form "width n" and the other of which is "height m", where n and m are positive integers. These indicate the size of the map. The reading will fail if these are not included.
All other lines before the "map" line will be discarded.
file_name | The name of the file to read. |
void MapPathfindingTransitions::set4Connected | ( | ) |
Sets the map to be 4-connected.
void MapPathfindingTransitions::set8Connected | ( | ) |
Sets the map to be 8-connected.
bool MapPathfindingTransitions::setDiagonalCost | ( | double | d_cost | ) |
Sets the cost of diagonal move (ie. northeast, southeast, southwest, or northwest). By default, set as square root two, as defined in floating_point_utils.h.
Ignores the given value if it is non-positive.
d_cost | The cost of a diagonal move. |
|
protected |
The cost of a diagonal move.
|
protected |
If the map is 4-connected or 8-connected.
|
protected |
Indexed by location, indicates if it is empty or an obstacle.
|
protected |
The map height.
|
protected |
The map width.