libcoyotl::maze Class Reference
Defines the data structure of a
maze.
More...
#include <maze.h>
List of all members.
Public Types
Public Member Functions
Static Public Member Functions
- static maze generate (size_t a_width, size_t a_height, architect &a_architect)
- Constructor.
- static maze load (std::istream &a_source)
- A "named constructor" to load a maze from an istream.
Protected Member Functions
- maze (size_t a_width, size_t a_height)
- Constructor without an architect (for use by load).
- void construct ()
- Allocates memory and sets intial values for a maze.
- void release ()
- Utility method to delete all data buffers.
- void deep_copy (const maze &a_source)
- Deep copy utility.
- void read (std::istream &a_source)
- Utility method to read a maze.
Protected Attributes
Friends
-
class architect
- This is a friend so derived types can access maze elements.
Classes
Detailed Description
A
maze object contains the definition of a rectangular
maze, including dimensions, wall placement, and entrance and exit locations. The
maze class does not include intrinsic support for rendering images or genetic algorithms; instead, it contains a generated set of tables used by algorithms implementing those features. As such, the class implements a variety of interrogation functions meant to provide read-only access to internal data.
Member Enumeration Documentation
- Enumerator:
-
WALL_CLOSED |
> Wall is open |
WALL_SOLID |
> Wall is closed
> Walls is solid and can never be open (outside boundary) |
- Enumerator:
-
DIR_EAST |
> North (up) |
DIR_SOUTH |
> East (right) |
DIR_WEST |
> South (down)
> West (left) |
Constructor & Destructor Documentation
libcoyotl::maze::maze |
( |
const maze & |
a_source |
) |
|
Creates a new maze with a state matching an existing maze.
- Parameters:
-
virtual libcoyotl::maze::~maze |
( |
|
) |
[virtual] |
Destroys a maze objet and releases all of its resources.
libcoyotl::maze::maze |
( |
size_t |
a_width, |
|
|
size_t |
a_height | |
|
) |
| | [protected] |
This constructor sets parameters, and then calls construct to allocate memory and assign default walls.
- Parameters:
-
| a_width | - Width, in cells, of the new maze |
| a_height | - Height, in cells, of the new maze |
- See also:
- maze::generate
Member Function Documentation
static maze libcoyotl::maze::generate |
( |
size_t |
a_width, |
|
|
size_t |
a_height, |
|
|
architect & |
a_architect | |
|
) |
| | [static] |
Creates a new maze with the specified dimensions and a floor plan defined by the given architect.
- Parameters:
-
| a_width | - Width, in cells, of the new maze |
| a_height | - Height, in cells, of the new maze |
| a_architect | - Architect to design a floorplan |
- Returns:
- A new maze object
static maze libcoyotl::maze::load |
( |
std::istream & |
a_source |
) |
[static] |
Loads a maze from a binary file created using maze::save.
- Parameters:
-
| a_source | - Input stream containing the binary maze |
- Returns:
- A new maze object
maze& libcoyotl::maze::operator= |
( |
const maze & |
a_source |
) |
|
Sets the state of a new maze to match the state of an existing maze.
- Parameters:
-
void libcoyotl::maze::save |
( |
std::ostream & |
a_receiver |
) |
|
Saves a maze to an output stream in binary format. This stream can later be used to reconstitute the maze via the load named constructor.
- Parameters:
-
| a_receiver | - Output stream to hold the binary maze object |
size_t libcoyotl::maze::get_width |
( |
|
) |
const [inline] |
size_t libcoyotl::maze::get_height |
( |
|
) |
const [inline] |
position libcoyotl::maze::get_entrance_cell_position |
( |
|
) |
const [inline] |
position libcoyotl::maze::get_exit_cell_position |
( |
|
) |
const [inline] |
cell libcoyotl::maze::get_cell |
( |
size_t |
a_col, |
|
|
size_t |
a_row | |
|
) |
| | const |
Returns data for a specific cell in a maze.
- Parameters:
-
| a_col | - Column of the requested cell |
| a_row | - Row of the requested cell |
- Returns:
- Cell data
void libcoyotl::maze::construct |
( |
|
) |
[protected] |
This constructor creates the raw maze, with all walls solid or closed. It is used by the named constructor generate
void libcoyotl::maze::release |
( |
|
) |
[protected] |
Releases resources allocated to a maze.
void libcoyotl::maze::deep_copy |
( |
const maze & |
a_source |
) |
[protected] |
Performs a deep copy of one maze to another.
- Parameters:
-
void libcoyotl::maze::read |
( |
std::istream & |
a_source |
) |
[protected] |
Read a maze's data from a binary stream.
- Parameters:
-
| a_source | - Input stream containing the binary maze |
The documentation for this class was generated from the following file: