57#include <gtest/gtest.h>
81 std::uniform_real_distribution<double> u(0.0, 1.0);
85 g.set({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)},
95 if (g.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}) != 0)
102 if (a.size(0) != b.size(0)
or a.size(1) != b.size(1))
104 for (
ca_size_t i = 0; i < a.size(0); ++i)
105 for (
ca_size_t j = 0; j < a.size(1); ++j)
106 if (a.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)})
107 != b.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}))
118 static const std::uint32_t seeds[] = {
119 0x00000001u, 0xC0FFEEu, 0xDEADBEEFu, 0xFEEDFACEu,
120 0xABCDEF01u, 0x13572468u, 0x9E3779B9u, 0x5BD1E995u};
122 for (std::uint32_t s : seeds)
152 for (std::size_t t = 0; t < 60; ++t)
156 <<
"BBM lost particles (seed=" <<
seed <<
", side=" <<
side
157 <<
", step=" << t <<
")";
161 EXPECT_GE(
grids, 20) <<
"property must sweep enough random grids";
172 for (std::size_t t = 0; t < 60; ++t)
176 <<
"TM Gas lost particles (seed=" <<
seed <<
", side=" <<
side
177 <<
", step=" << t <<
")";
189template <
typename Block_Rule>
202 const std::size_t
N = 300;
204 << label <<
" forward threw (seed=" <<
seed <<
")";
206 << label <<
" backward threw (seed=" <<
seed <<
")";
209 << label <<
": forward(" <<
N <<
") then backward(" <<
N
210 <<
") must restore the initial state (seed=" <<
seed
211 <<
", side=" << s <<
")";
248 for (std::size_t t = 0; t < 40; ++t)
251 <<
"non-deterministic frame (seed=" <<
seed <<
", step=" << t <<
")";
268 std::mt19937
rng(
seed ^ 0xA5A5A5A5u);
271 std::uniform_int_distribution<int> coord(-4 *
static_cast<int>(
side),
272 4 *
static_cast<int>(
side));
273 for (
int k = 0;
k < 200; ++
k)
277 const int v = g.at_safe({
r, c});
281 <<
"at_safe returned out-of-domain value " << v
282 <<
" at (" <<
r <<
", " << c <<
")";
287 <<
"at_safe disagrees with toroidal wrap at (" <<
r <<
", " << c
Common typedefs and tag types for the Cellular Automata module.
Update-scheme aware engine.
Fredkin–Toffoli Billiard Ball Machine block rule.
Critters reversible CA block rule.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Placeholder neighbourhood for engines that drive block rules.
Synchronous double-buffered engine.
void step()
Apply the rule to every cell once and swap buffers.
Toffoli–Margolus (TM) lattice-gas block rule.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
constexpr Game_Of_Life_Rule make_game_of_life_rule() noexcept
Build the canonical Game of Life rule.
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
Margolus 2×2 partition update for reversible CAs.
The lattice wraps around on every axis.
FooMap m(5, fst_unit_pair_hash, snd_unit_pair_hash)
Phase 13 update-scheme aware engine.
Block-based local rules for Aleph::CA (Phase 13).
Synchronous double-buffered engine for cellular automata.
Cellular automata lattice with pluggable boundary policies.
Neighborhoods catalogue for Aleph::CA.
Rule mechanisms for Aleph::CA.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).
Phase 13 update-scheme strategies for Aleph::CA.