2#include "../core/rng.hpp"
3#include "../core/exceptions.hpp"
10 void normal(T* array,
const unsigned int h,
const unsigned int w)
12 for (
int i = 0; i < h * w; i++)
14 array[i] = CellularAutomata::random::random<T>(0, 1);
19 void binary(T* array,
const unsigned int h,
const unsigned int w)
21 for (
int i = 0; i < h * w; i++)
23 if (CellularAutomata::random::random<float>(0, 1) > 0.5)
25 array[i] =
static_cast<T
>(1);
29 array[i] =
static_cast<T
>(0);
37 inline void copyInto(T* src,
const unsigned int src_h,
const unsigned int src_w, T* dst,
const unsigned int dst_h,
const unsigned int dst_w,
const unsigned int y,
const unsigned int x)
39 if (src_h + y > dst_h || src_w + x > dst_w)
43 for (
int _y = y; _y < y + src_h; _y++)
45 for (
int _x = x; _x < x + src_w; _x++)
47 dst[_y * dst_w + _x] = src[i];
101 template <
typename T>
2D buffered matrices
Definition common.hpp:56
const unsigned int width
Width of 2D Matrix.
Definition common.hpp:76
T * curr
Current 2D Matrix buffer.
Definition common.hpp:61
const unsigned int height
Height of 2D Matrix.
Definition common.hpp:71
Accessed a value outside the bounds of matrix.
Definition exceptions.hpp:46
void Bipole2(State< T > *state, const unsigned int x, const unsigned int y)
Copies a (alternative) bipole (5x5) into given position (https://conwaylife.com/wiki/Bipole)
Definition states.inl:89
void Bipole1(State< T > *state, const unsigned int x, const unsigned int y)
Copies a bipole (4x4) into given position (https://conwaylife.com/wiki/Bipole)
Definition states.inl:77
void r_Pentomino(State< T > *state, const unsigned int x, const unsigned int y)
Copies a R-pentomino (3x3) into given position (https://conwaylife.com/wiki/R-pentomino)
Definition states.inl:102
void copyInto(T *src, const unsigned int src_h, const unsigned int src_w, T *dst, const unsigned int dst_h, const unsigned int dst_w, const unsigned int y, const unsigned int x)
Copy an (small) array into another (large) array at a given position.
Definition states.inl:37
void Glider(State< T > *state, const unsigned int x, const unsigned int y)
Copies a glider (3x3) into given position (https://conwaylife.com/wiki/Glider)
Definition states.inl:54
void Spaceship(State< T > *state, const unsigned int x, const unsigned int y)
Copies a spaceship (4x5) into given position (https://conwaylife.com/wiki/Spaceship)
Definition states.inl:65
void binary(T *array, const unsigned int h, const unsigned int w)
Fills the kernel with either 0 or 1.
Definition states.inl:19
void normal(T *array, const unsigned int h, const unsigned int w)
Fills the kernel with values between [0, 1].
Definition states.inl:10
Main namespace.
Definition common.hpp:33