#include <Automaton.h>
Public Member Functions | |
Automaton (T *gridPointer, int Dsizes[], int dimesions) | |
The constructor. | |
Automaton (const Automaton &a) | |
The copy-constructor:. | |
Automaton & | operator= (const Automaton &a) |
Overwrite the = operator to avoid problems when you forget initialize whit the constructor. | |
void | setMap () |
Set the Map objects, that unifies the desired form of the graph given by the Topology with the possible form given by the Neighborhood. | |
void | getMap () |
Return the Map "mixer" object of this Automaton. | |
void | setNeighborhood () |
Set the Neighborhood object of this class, that determine the desired form of the graph. | |
void | getNeighborhood () |
Return the Neighborhood object of this Automaton. | |
void | iterateOverTheSatesArray (int index=0) |
With this function you can iterate over an array independently of the dimension and element type of the array. | |
void | createNode () |
This method is for creating the structure (the Node) container of the couple's node and edges. | |
void | getNodePointer (std::vector< int > position) |
This method change the copyPointerToNodes pointer to point a element in the states array given by the position argument. | |
void | getNodePointer (int position[]) |
This method is equal to getNodePointer except use an array as n input instead a vector. | |
void | getNodePointer () |
This method do the same that getNodePointer(int position[]) but use copyDimSizes array instead input. | |
Public Attributes | |
std::vector< int > | position |
This vector is used in createNode() method for a lack of compatibility with the Map class, soon is going to be eliminated. | |
T * | pointerToNodes |
The pointer to the states matrix. | |
T * | copyPointerToNodes |
This is the pointer that is actually moved across the state matrix. | |
T * | copyPointerToNodes2 |
In createNode()there is a need to an extra copy of copyPointerToNodes variable. | |
std::vector< T * > | neighbors |
The pointers container to the state matrix. | |
std::vector< Node > | graph |
the Node container. | |
int | dimSizes [maxDimensions] |
The array of dimensions sizes. | |
int | copyDimSizes [maxDimensions] |
A copy of dimSizes array is used to apply some changes in the dimSizes array without lost is information. | |
int | dimension |
The number of dimensions in the Automaton. | |
int | indexHood |
Index value to determine starts and finish int values in the Node structure. | |
Map * | map |
The Automaton needs a Map object to determine the actual form of the graph. | |
Topology * | topology |
The Topology object determines the possible form of the graph. | |
Neighborhood * | neighborhood |
The Neighborhood object determines the desired form of the graph. | |
int | states |
The states variable is for combinatory. | |
Static Public Attributes | |
static const int | maxDimensions = 100 |
The maximum dimensions number. | |
Classes | |
struct | Node |
This structure represent a vertex in graph with all is properties. More... |
This class uses a type of neighborhood and a type of topology in a map class, to create the final graph, this graph is a net of references to a matrix, the base element matrix. This class contain the next step function, the method to calculate the next inner states of the elements in the base element matrix, given by the graph form and the change state algorithm given by the method.
void Automaton< T >::createNode | ( | ) |
This method is for creating the structure (the Node) container of the couple's node and edges.
The "structures" container is the graph, and the structure consist of a center pointer to the states matrix, the node, and two index for the beginning and end of the neighbors positions index in the vector container, the edges (links to neighbors).
This method use the copyDimSizes position array, this vector define the node coordinates in the grid, and the Map class is used to find if the edge exist and in the case generate is coordinates, Map is the uses the Topology class and the Neighborhood class. The generated edge (pointer to element in the state array) is keep, in the neighbors vector container, and the index values in the Node structure in particular the end index is modify.
void Automaton< T >::getNodePointer | ( | ) |
This method do the same that getNodePointer(int position[]) but use copyDimSizes array instead input.
Use the copyDimSizes array as the coordinates of the element in the state array to point to in copyPointerToNodes pointer.
void Automaton< T >::getNodePointer | ( | int | position[] | ) |
This method is equal to getNodePointer except use an array as n input instead a vector.
Watch the getNodePointer method documentation.
void Automaton< T >::getNodePointer | ( | std::vector< int > | position | ) |
This method change the copyPointerToNodes pointer to point a element in the states array given by the position argument.
If you want to access any element in a multi-dimensional array, use a pointer to the first element and advance the pointer to the position of the element that you want to change/access. The reference pointer is pointerToNodes, mark the start bunch of memory use by the states array, and the values to know how much positions move to pass from one dimension to the next one in the array is give by dimSizes array. The pointer copyPointerToNodes finish pointing to the desired position in the states array.
void Automaton< T >::iterateOverTheSatesArray | ( | int | index = 0 |
) |
With this function you can iterate over an array independently of the dimension and element type of the array.
This is done tanks to the pointer to the first element of the array pointerToNodes, and the dimension sizes array dimSizes[maxDimensions]. The pointer as starting point reference and the array is for know how many places move the pointer to go from one position to other in the states matrix, because the multidimensional arrays are keep has memory places one next to the other. In this method you iterate over the states array calling the createNode() method, for each element in the array, each element is a "center cell", the "nodes" in the graph. All the edges and final graph structure is set in every time is call the createNode() method.
T* Automaton< T >::copyPointerToNodes |
This is the pointer that is actually moved across the state matrix.
Is used to keep the reference to the start of the matrix given by pointerToNodes variable.
int Automaton< T >::dimSizes[maxDimensions] |
The array of dimensions sizes.
Every element in the dimSizes array represents a size of some dimension; This array has fixed long size, the maxDimensions variable, if the dimension variable, the dimension for this Automaton object is smaller than the size of this array, each element pass the dimension number is not taken account and is ignored. The Automaton dimension cant be bigger than the size of this array.
Index value to determine starts and finish int values in the Node structure.
This int value is to accomplish the calculations and keep track of where starts, and where finish a neighborhood in the vertex's vector container (in the createNode() method).
The Automaton needs a Map object to determine the actual form of the graph.
With this object the form of the graph is developed in base of the "desired" form given by the Neighborhood object and the "possible" form given by the topology object.
const int Automaton< T >::maxDimensions = 100 [static] |
The maximum dimensions number.
To accomplish all the calculations and maintain the possibility to use n-dimensional matrixes, we create an array to keep all the dimension sizes, this array need an initial size value a const int variable type; The maxDimensions is this type, so for now we have the possibility to use a maximum dimensions number of 100.
The pointers container to the state matrix.
Represents the edges in the graph, the neighbors in the cellular automata
T* Automaton< T >::pointerToNodes |
The pointer to the states matrix.
This pointer is used to move across the states matrix, in this way the program works independently of the dimension of the states matrix.