9 #ifndef PARALLEL_CELLULAR_AUTOMATA_SEQUENTIAL_AUTOMATON_HPP
10 #define PARALLEL_CELLULAR_AUTOMATA_SEQUENTIAL_AUTOMATON_HPP
15 #ifndef PARALLEL_CELLULAR_AUTOMATA_CELLULAR_AUTOMATA_HPP
59 grid = std::move(other.grid);
89 for (
size_t r{0}; r <
grid.rows(); ++r)
91 for (
size_t c{0}; c <
grid.columns(); ++c)
93 auto cell = std::make_tuple(
grid(r, c));
126 return os <<
ca.grid;
173 unsigned rows =
grid.rows();
174 unsigned columns =
grid.columns();
175 T top_left, top, top_right, left, right, bottom_left, bottom, bottom_right;
176 top_left =
grid((row - 1 + rows) % rows, (col - 1 + columns) % columns);
177 top =
grid((row - 1 + rows) % rows, col);
178 top_right =
grid((row - 1 + rows) % rows, (col + 1) % columns);
179 left =
grid(row, (col - 1 + columns) % columns);
180 right =
grid(row, (col + 1) % columns);
181 bottom_left =
grid((row + 1) % rows, (col - 1 + columns) % columns);
182 bottom =
grid((row + 1) % rows, col);
183 bottom_right =
grid((row + 1) % rows, (col + 1) % columns);
184 return std::make_tuple(top_left, top, top_right, left, right, bottom_left, bottom, bottom_right);
This header imports all the other headers of the framework.
Grid of the cellular automaton.
Definition: grid.hpp:31
static Grid newWithSameSize(const Grid &other)
Return a grid of the same dimension of the grid passed as argument.
Definition: grid.hpp:95
Sequential Cellular Automaton.
Definition: sequential_automaton.hpp:38
CellularAutomaton(const CellularAutomaton &other)=delete
Deleted copy constructor.
std::function< T(T, T, T, T, T, T, T, T, T)> update_function
Function used to compute the next state of the cell.
Definition: sequential_automaton.hpp:151
virtual void simulate(unsigned steps=1)
Run the simulation for a given number of steps.
Definition: sequential_automaton.hpp:79
virtual size_t get_generation() const
Get the generation of the simulation.
Definition: sequential_automaton.hpp:110
Grid< T > & grid
Grid of the C.A.
Definition: sequential_automaton.hpp:134
size_t generation
Current generation of the grid.
Definition: sequential_automaton.hpp:140
CellularAutomaton(Grid< T > &grid, std::function< T(T, T, T, T, T, T, T, T, T)> update_function)
Construct a new Cellular Automaton object.
Definition: sequential_automaton.hpp:47
friend std::ostream & operator<<(std::ostream &os, const CellularAutomaton &ca)
Overload of the << operator.
Definition: sequential_automaton.hpp:123
virtual std::tuple< T, T, T, T, T, T, T, T > get_neighborhood(int row, int col) const
Get the neighborhood of a cell.
Definition: sequential_automaton.hpp:170
CellularAutomaton(CellularAutomaton &&other)
Construct a new Cellular Automaton object from another one using move semantic.
Definition: sequential_automaton.hpp:56
Definition of the grid of the automaton.
Namespace of the framework.
Definition: barrier.hpp:20