54#include <gtest/gtest.h>
86 template <
typename Boundary, std::
size_t H = 1>
93 g.
set({ i, j },
static_cast<int>(i * 10 + j));
99 template <
typename Boundary>
106 lat.
set({ i, j },
static_cast<int>(i * 10 + j));
141 EXPECT_EQ(g.store_extents()[0], 4u + 4u);
142 EXPECT_EQ(g.store_extents()[1], 5u + 4u);
250 g.
set({ i, j },
static_cast<int>(i * 10 + j));
266 EXPECT_EQ(g.at_safe({ -1, 1 }),
lat.at_safe({ -1, 1 }));
268 EXPECT_EQ(g.at_safe({ 1, -1 }),
lat.at_safe({ 1, -1 }));
272 EXPECT_EQ(g.at_safe({ -1, -1 }),
lat.at_safe({ -1, -1 }));
297 EXPECT_EQ(g.at_safe({ -1, 1 }), g.at({ 0, 1 }));
298 EXPECT_EQ(g.at_safe({ 3, 1 }), g.at({ 2, 1 }));
299 EXPECT_EQ(g.at_safe({ 1, -1 }), g.at({ 1, 0 }));
300 EXPECT_EQ(g.at_safe({ 1, 3 }), g.at({ 1, 2 }));
302 EXPECT_EQ(g.at_safe({ -1, -1 }), g.at({ 0, 0 }));
303 EXPECT_EQ(g.at_safe({ 3, 3 }), g.at({ 2, 2 }));
311template <
typename Boundary>
321 EXPECT_EQ(g.at_safe({ i, j }),
l.at_safe({ i, j }))
322 <<
"mismatch at (" << i <<
", " << j <<
")";
350 g.set({ i, j },
static_cast<int>(i * 10 + j));
351 l.set({ i, j },
static_cast<int>(i * 10 + j));
356 EXPECT_EQ(g.at_safe({ i, j }),
l.at_safe({ i, j }))
357 <<
"mismatch at (" << i <<
", " << j <<
")";
373 EXPECT_EQ(g.at_safe({ i, j }),
l.at_safe({ i, j }));
376 EXPECT_EQ(g.at_safe({ -2, 1 }),
l.at_safe({ -2, 1 }));
377 EXPECT_EQ(g.at_safe({ 4, 1 }),
l.at_safe({ 4, 1 }));
378 EXPECT_EQ(g.at_safe({ 1, -2 }),
l.at_safe({ 1, -2 }));
379 EXPECT_EQ(g.at_safe({ 1, 4 }),
l.at_safe({ 1, 4 }));
380 EXPECT_EQ(g.at_safe({ -2, -2 }),
l.at_safe({ -2, -2 }));
381 EXPECT_EQ(g.at_safe({ 4, 4 }),
l.at_safe({ 4, 4 }));
385 EXPECT_EQ(g.at_safe({ -3, 1 }),
l.at_safe({ -3, 1 }));
386 EXPECT_EQ(g.at_safe({ 5, 1 }),
l.at_safe({ 5, 1 }));
399 g.set({ i },
static_cast<int>(i + 1));
400 l.set({ i },
static_cast<int>(i + 1));
404 EXPECT_EQ(g.at_safe({ i }),
l.at_safe({ i }));
420 g.set({ i, j,
k }, v);
421 l.set({ i, j,
k }, v);
428 EXPECT_EQ(g.at_safe({ i, j, k }),
l.at_safe({ i, j, k }));
461 lat.set({
ci - 1,
cj + 1 }, 1);
467 template <
typename L>
470 if (a.size(0) != b.size(0)
or a.size(1) != b.size(1))
474 if (a.at({ i, j }) != b.at({ i, j }))
479 template <
typename A,
typename B>
482 if (a.size(0) != b.size(0)
or a.size(1) != b.size(1))
486 if (a.at({ i, j }) != b.at({ i, j }))
492template <
typename Boundary>
513 for (std::size_t s = 0; s <
steps; ++s)
518 <<
"frames diverge at step " << s + 1;
565 struct R2_Parity_Functor
567 constexpr int operator()(
const int &, std::size_t alive)
const noexcept
569 return alive % 2 == 0 ? 0 : 1;
598 for (std::size_t s = 0; s < 60; ++s)
603 <<
"R=2 frames diverge at step " << s + 1;
Common typedefs and tag types for the Cellular Automata module.
Row-major dense storage for N-dimensional cellular automata.
Lattice with Halo ghost layers around the user-visible cells.
void set(const coord_type &c, const state_type &v)
Strict write through a user coordinate.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Rule whose next state depends on (current, alive_count).
Synchronous double-buffered engine.
void step()
Apply the rule to every cell once and swap buffers.
Von Neumann (L1) neighborhood of radius R in N dimensions.
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.
Zero-gradient (Neumann) boundary.
Out-of-range neighbours behave as if the lattice ended.
Out-of-range coordinates mirror back into the lattice.
The lattice wraps around on every axis.
C++20 concepts for the Cellular Automata module.
Synchronous double-buffered engine for cellular automata.
Ghost-layer lattice for high-performance boundary handling.
static void expect_equivalent_at_safe()
static void run_engine_equivalence(std::size_t steps)
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).