Peekerpoke  0.1 beta
Map Class Reference

#include <Map.h>

Public Member Functions

 Map ()
 call the function initial() More...
 
 ~Map ()
 
void updateNextPosition ()
 try to search for the path to the destination More...
 
bool nextPositionAvilable ()
 check for the nextPosition if it is avialable More...
 
direction getCurrentDirection ()
 getter function of currentDirection More...
 
void setCurrentDirection (direction _currentDirection)
 setter function of currentDirection More...
 
int compareCurrent2nextDirection (char axis)
 compare current direction with next direction More...
 
void printPosition (int index)
 Print three position in the specific format. More...
 
bool arriveDestination ()
 Check if has reached the destination. More...
 
void printMap ()
 Print the map in a specific format. More...
 
point getNextPosition ()
 getter function of nextPosition More...
 
point getCurrentPosition ()
 getter function of currentPosition More...
 
int getMapAtPosition (const int &position)
 getter function of the status of a specfic position in the map More...
 
void setCurrentPosition (const point &p)
 setter function of currentPosition More...
 
void setMapAtPosition (const point &p, const int &value)
 setter function of a position in the map More...
 

Private Member Functions

void initMatrix ()
 initial the map according to your idea More...
 
void initDestination ()
 initial the distination according to your idea More...
 
void initCurrentAndNextPosition ()
 initial the current position according to your idea More...
 
void initCurrentDirection ()
 initial the current direction according to your idea More...
 
void initial ()
 initial the Map parameters More...
 
void initDfs ()
 initial the dfs parameters for function dfs() More...
 
bool dfsPointValid (const point &p)
 Judge a point if it is in the map, never visited and reachable. More...
 
void printPath (int length)
 Print the path to destination in the specific format. More...
 
bool dfs (point cur, int step)
 Find a path to the destination via dfs. More...
 

Private Attributes

int matrix [MAP_ROWS][MAP_COLUMNS]
 
bool visited [MAP_ROWS][MAP_COLUMNS]
 
point path [PATH_LENGTH]
 
point destination
 
point currentPosition
 
direction currentDirection
 
point nextPosition
 

Constructor & Destructor Documentation

Map::Map ( )

call the function initial()

Map::~Map ( )

Member Function Documentation

bool Map::arriveDestination ( )

Check if has reached the destination.

Returns
true - reached
false - otherwise
int Map::compareCurrent2nextDirection ( char  axis)

compare current direction with next direction

Parameters
axisa char symbol for the compare axis, 'x' or 'y'
Returns
0 - equal
1 - current > next
-1 - current < next
bool Map::dfs ( point  cur,
int  step 
)
private

Find a path to the destination via dfs.

Parameters
cura point of where the car is now
stephow many steps has the car searched
Returns
true - can find such a path
false - otherwise
Precondition
call function initDfs()
bool Map::dfsPointValid ( const point p)
private

Judge a point if it is in the map, never visited and reachable.

Parameters
pa point to be judged
Returns
true - in the map, never visited and reachable
false - otherwise
direction Map::getCurrentDirection ( )

getter function of currentDirection

Returns
currentDirection
point Map::getCurrentPosition ( )

getter function of currentPosition

Returns
currentPosition
int Map::getMapAtPosition ( const int &  position)

getter function of the status of a specfic position in the map

Parameters
positionan int wich means the position you want formatted like 74
Returns
the status of the point
point Map::getNextPosition ( )

getter function of nextPosition

Returns
nextPosition
void Map::initCurrentAndNextPosition ( )
private

initial the current position according to your idea

initial the next position same as current position

void Map::initCurrentDirection ( )
private

initial the current direction according to your idea

void Map::initDestination ( )
private

initial the distination according to your idea

void Map::initDfs ( )
private

initial the dfs parameters for function dfs()

void Map::initial ( )
private

initial the Map parameters

void Map::initMatrix ( )
private

initial the map according to your idea

bool Map::nextPositionAvilable ( )

check for the nextPosition if it is avialable

Returns
true - reachable
false - unreachable
void Map::printMap ( )

Print the map in a specific format.

void Map::printPath ( int  length)
private

Print the path to destination in the specific format.

Parameters
lengththe length of the path
void Map::printPosition ( int  index)

Print three position in the specific format.

Parameters
indexan int symbol 1 - Current Position 2 - Next Position 3 - Destination
void Map::setCurrentDirection ( direction  _currentDirection)

setter function of currentDirection

Parameters
_currentDirectiona new currentDirection
void Map::setCurrentPosition ( const point p)

setter function of currentPosition

Parameters
pnew currentPosition
void Map::setMapAtPosition ( const point p,
const int &  value 
)

setter function of a position in the map

Parameters
pthe position which you want to set
valuethe status of the position which you want to set
void Map::updateNextPosition ( )

try to search for the path to the destination

If serach successfully, update the nextPosition, else set the nextPosition unreachable

Member Data Documentation

direction Map::currentDirection
private
point Map::currentPosition
private
point Map::destination
private
int Map::matrix[MAP_ROWS][MAP_COLUMNS]
private
point Map::nextPosition
private
point Map::path[PATH_LENGTH]
private
bool Map::visited[MAP_ROWS][MAP_COLUMNS]
private

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