|
| CellularAutomaton (ca::Grid< T > &grid, std::function< T(T, T, T, T, T, T, T, T, T)> update_function, unsigned workers=0) |
| Construct a new Cellular Automaton object. More...
|
|
| CellularAutomaton (CellularAutomaton &&other) |
| Construct a new Cellular Automaton object from another one using move semantic. More...
|
|
| CellularAutomaton (const CellularAutomaton &other)=delete |
| Deleted copy constructor. More...
|
|
virtual void | simulate (unsigned steps=1) |
| Run the simulation for a given number of steps. More...
|
|
virtual size_t | get_generation () const |
| Get the generation of the simulation. More...
|
|
|
virtual std::tuple< T, T, T, T, T, T, T, T > | get_neighborhood (int row, int col) const |
| Get the neighborhood of a cell. More...
|
|
◆ CellularAutomaton() [1/3]
template<typename T >
ca::par::bw::CellularAutomaton< T >::CellularAutomaton |
( |
ca::Grid< T > & |
grid, |
|
|
std::function< T(T, T, T, T, T, T, T, T, T)> |
update_function, |
|
|
unsigned |
workers = 0 |
|
) |
| |
|
inline |
Construct a new Cellular Automaton object.
- Parameters
-
grid | Grid of the simulation. |
rows | Number of rows of the grid. |
columns | Number of columns of the grid. |
update_function | Function used to update the state of the grid. |
nw | Number of workers (0 == hadrwareconcurrency) (default 0). |
◆ CellularAutomaton() [2/3]
Construct a new Cellular Automaton object from another one using move semantic.
- Note
- The old object will be left in a valid but unspecified state.
- Parameters
-
◆ CellularAutomaton() [3/3]
Deleted copy constructor.
- Note
- The copy constructor has been deleted since the class uses a pointer to a user defined grid and the freeing of the grid is up to them.
◆ get_generation()
Get the generation of the simulation.
- Returns
- size_t value of the generation member variable.
◆ get_neighborhood()
Get the neighborhood of a cell.
+----+-----------+----+
| TL | T | TR |
+----+-----------+----+
| L | (row,col) | R |
+----+-----------+----+
| BL | B | BR |
+----+-----------+----+
- Precondition
- 0 <= row < rows.
-
0 <= col < columns.
- Parameters
-
row | row of the center cell. |
col | column of the center cell. |
- Returns
- std::tuple<T, T, T, T, T, T, T, T> containing <TL, T, TR, L, R, BL, B, BR>
◆ simulate()
Run the simulation for a given number of steps.
- Parameters
-
steps | number of simulation steps to run (default 1). |
- Postcondition
- grid contains the result of the simulation and generation = generation + steps.
◆ operator<<
Overload of the << operator.
Print the grid on a output stream.
- Parameters
-
- Returns
- std::ostream& reference to the output stream
◆ update_function
Function used to compute the next state of the cell.
The function takes nine arguments. It will be called by passing the central cell as first argument and its eight neighbors as the remaining arguments. Their order is the one returned by the get_neighborhood function.
- See also
- get_neighborhood
The documentation for this class was generated from the following file: