Created by Scott Robert Ladd at Coyote Gulch Productions.
Defines the data structure of a maze. More...
#include <maze.h>
Classes | |
| class | architect |
| Pluggable object to randomize a maze. More... | |
| struct | cell |
| A cell in a 2D maze grid. More... | |
| struct | position |
| A row-column position in the maze. More... | |
Public Types | |
| enum | wall { WALL_OPEN, WALL_CLOSED, WALL_SOLID } |
| The state of a wall. More... | |
| enum | direction { DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST } |
| Wall identifiers for the four cardinal directions. More... | |
Public Member Functions | |
| maze (const maze &a_source) | |
| Copy constructor. More... | |
| maze & | operator= (const maze &a_source) |
| Assignment operator. More... | |
| virtual | ~maze () |
| Destructor. More... | |
| void | save (std::ostream &a_receiver) |
| Store a maze to a stream. More... | |
| size_t | get_width () const |
| Return the width of the maze. More... | |
| size_t | get_height () const |
| Return the height of the maze. More... | |
| position | get_entrance_cell_position () const |
| Get the entrance cell position. More... | |
| position | get_exit_cell_position () const |
| Get the exit cell position. More... | |
| cell | get_cell (size_t a_col, size_t a_row) const |
| Get cell data. More... | |
Static Public Member Functions | |
| static maze | generate (size_t a_width, size_t a_height, architect &a_architect) |
| Constructor. More... | |
| static maze | load (std::istream &a_source) |
| A "named constructor" to load a maze from an istream. More... | |
Protected Member Functions | |
| maze (size_t a_width, size_t a_height) | |
| Constructor without an architect (for use by load) More... | |
| void | construct () |
| Allocates memory and sets intial values for a maze. More... | |
| void | release () |
| Utility method to delete all data buffers. More... | |
| void | deep_copy (const maze &a_source) |
| Deep copy utility. More... | |
| void | read (std::istream &a_source) |
| Utility method to read a maze. More... | |
Protected Attributes | |
| size_t | m_width |
| Width of the maze in cells. | |
| size_t | m_height |
| Height of the maze in cells. | |
| position | m_entrance |
| Position of the entrance cell. | |
| position | m_exit |
| Position of the exit cell. | |
| cell ** | m_cells |
| The cell data. | |
Friends | |
| class | architect |
| This is a friend so derived types can access maze elements. | |
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.
| libcoyotl::maze::maze | ( | const maze & | a_source | ) |
Creates a new maze with a state matching an existing maze.
| a_source | - Source object |
Referenced by get_exit_cell_position().
|
virtual |
Destroys a maze objet and releases all of its resources.
|
protected |
This constructor sets parameters, and then calls construct to allocate memory and assign default walls.
| a_width | - Width, in cells, of the new maze |
| a_height | - Height, in cells, of the new maze |
|
protected |
This constructor creates the raw maze, with all walls solid or closed. It is used by the named constructor generate
Referenced by get_exit_cell_position().
|
protected |
Performs a deep copy of one maze to another.
| a_source | - Source object |
Referenced by get_exit_cell_position().
|
static |
Creates a new maze with the specified dimensions and a floor plan defined by the given architect.
| 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 |
| cell libcoyotl::maze::get_cell | ( | size_t | a_col, |
| size_t | a_row | ||
| ) | const |
Returns data for a specific cell in a maze.
| a_col | - Column of the requested cell |
| a_row | - Row of the requested cell |
Referenced by get_exit_cell_position().
|
inline |
Returns the position of the entrance cell for a maze.
References m_entrance.
|
inline |
Returns the position of the exit cell for a maze.
References construct(), deep_copy(), get_cell(), m_exit, maze(), read(), and release().
|
inline |
|
inline |
|
static |
Loads a maze from a binary file created using maze::save.
| a_source | - Input stream containing the binary maze |
Sets the state of a new maze to match the state of an existing maze.
| a_source | - Source object |
|
protected |
Read a maze's data from a binary stream.
| a_source | - Input stream containing the binary maze |
Referenced by get_exit_cell_position().
|
protected |
Releases resources allocated to a maze.
Referenced by get_exit_cell_position().
| 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.
| a_receiver | - Output stream to hold the binary maze object |
© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.