Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

GridWorld Class Reference

#include <GridWorld.h>


Detailed Description

Definition at line 10 of file GridWorld.h.

List of all members.

Classes

struct  State
 Stores context used per node in path planning, stores row and column position. More...

Public Member Functions

 GridWorld ()
 default constructor, does nothing
 GridWorld (size_t r, size_t c)
 constructs empty world of the specified size
bool validate (const State &st) const
 allows validation on queue-pop instead of before queue-push
float heuristic (const State &st, const State &goal) const
 The heuristic function accepts the current state, and goal state, and should return an admissable (aka optimistic) estimate of the remaining cost.
const std::vector< std::pair
< float, GridWorld::State > > & 
expand (const State *parent, const State &st, const State &goal) const
 Generates a vector of successor states, paired with the cost to get to that state from st.
char & operator() (size_t r, size_t c)
 map cell accessor
char operator() (size_t r, size_t c) const
 map cell accessor
std::vector< char > & operator[] (size_t r)
 map row accessor
const std::vector< char > & operator[] (size_t r) const
 map row accessor
char & operator[] (const State &x)
 map cell accessor
char operator[] (const State &x) const
 map cell accessor

Private Attributes

std::vector< std::vector< char > > world
 storage for map, spaces are empty, non-spaces are blocked

Static Private Attributes

static const float HCOST = 1
 cost for horizontal moves
static const float VCOST = 2
 cost for vertical moves
static const float DCOST = hypotf(HCOST,VCOST)
 cost for diagonal moves: <=0 means disable diagonals

Friends

std::istream & operator>> (std::istream &is, GridWorld &gw)
 can read from istream (until end of stream), spaces are empty, non-spaces are blocked
std::ostream & operator<< (std::ostream &os, const GridWorld &gw)
 writes map to ostream

Constructor & Destructor Documentation

GridWorld::GridWorld (  ) 

default constructor, does nothing

Definition at line 49 of file GridWorld.h.

GridWorld::GridWorld ( size_t  r,
size_t  c 
)

constructs empty world of the specified size

Definition at line 52 of file GridWorld.h.


Member Function Documentation

const std::vector< std::pair< float, GridWorld::State > > & GridWorld::expand ( const State parent,
const State st,
const State goal 
) const

Generates a vector of successor states, paired with the cost to get to that state from st.

Note that this implementation returns a reference to a static instance, which is not thread safe but slightly faster

Definition at line 28 of file GridWorld.cc.

float GridWorld::heuristic ( const State st,
const State goal 
) const

The heuristic function accepts the current state, and goal state, and should return an admissable (aka optimistic) estimate of the remaining cost.

Definition at line 12 of file GridWorld.cc.

char GridWorld::operator() ( size_t  r,
size_t  c 
) const

map cell accessor

Definition at line 65 of file GridWorld.h.

char& GridWorld::operator() ( size_t  r,
size_t  c 
)

map cell accessor

Definition at line 64 of file GridWorld.h.

char GridWorld::operator[] ( const State x  )  const

map cell accessor

Definition at line 71 of file GridWorld.h.

char& GridWorld::operator[] ( const State x  ) 

map cell accessor

Definition at line 70 of file GridWorld.h.

const std::vector<char>& GridWorld::operator[] ( size_t  r  )  const

map row accessor

Definition at line 68 of file GridWorld.h.

std::vector<char>& GridWorld::operator[] ( size_t  r  ) 

map row accessor

Definition at line 67 of file GridWorld.h.

bool GridWorld::validate ( const State st  )  const

allows validation on queue-pop instead of before queue-push

Definition at line 55 of file GridWorld.h.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const GridWorld gw 
) [friend]

writes map to ostream

Definition at line 68 of file GridWorld.cc.

std::istream& operator>> ( std::istream &  is,
GridWorld gw 
) [friend]

can read from istream (until end of stream), spaces are empty, non-spaces are blocked

Definition at line 60 of file GridWorld.cc.


Member Data Documentation

const float GridWorld::DCOST = hypotf(HCOST,VCOST) [static, private]

cost for diagonal moves: <=0 means disable diagonals

Definition at line 13 of file GridWorld.h.

Referenced by expand(), and heuristic().

const float GridWorld::HCOST = 1 [static, private]

cost for horizontal moves

Definition at line 11 of file GridWorld.h.

Referenced by expand(), and heuristic().

const float GridWorld::VCOST = 2 [static, private]

cost for vertical moves

Definition at line 12 of file GridWorld.h.

Referenced by expand(), and heuristic().

std::vector< std::vector<char> > GridWorld::world [private]

storage for map, spaces are empty, non-spaces are blocked

Definition at line 21 of file GridWorld.h.

Referenced by expand(), operator()(), operator<<(), operator>>(), and operator[]().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:09 2016 by Doxygen 1.6.3