58 std::uniform_real_distribution<double> u(0.0, 1.0);
61 g.set({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)},
65void render(
const Grid &g, std::ostream &
os)
70 os << (g.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)})
81 if (a.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)})
82 != b.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}))
87std::size_t alive(
const Grid &g)
92 if (g.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}) != 0)
101 std::size_t
steps = 1000;
107 steps =
static_cast<std::size_t
>(std::stoul(
argv[1]));
114 const unsigned long long s = std::stoull(
argv[3],
nullptr, 0);
115 if (s > std::numeric_limits<std::uint32_t>::max())
116 throw std::out_of_range(
"seed");
120 catch (
const std::invalid_argument &)
122 std::cerr <<
"Invalid argument: expected non-negative integers for "
123 "[steps] [side] [seed]\n";
126 catch (
const std::out_of_range &)
128 std::cerr <<
"Argument out of range for [steps] [side] [seed]\n";
138 std::cerr <<
"Invalid side: " <<
side
139 <<
" (must be a positive even integer ≥ 2 for Margolus reversibility)\n";
147 std::cout <<
"Critters reversible CA — " <<
side <<
"×" <<
side
149 << std::dec <<
"\n\n";
150 std::cout <<
"Initial frame (" << alive(
initial) <<
" alive):\n";
158 std::cout <<
"\nAfter forward(" <<
steps <<
") steps ("
159 << alive(
engine.frame()) <<
" alive):\n";
164 std::cout <<
"\nAfter backward(" <<
steps <<
") steps ("
165 << alive(
engine.frame()) <<
" alive):\n";
169 std::cout <<
"\nReversibility check: "
170 << (ok ?
"PASS — bit-exact identity recovered"
171 :
"FAIL — recovered frame differs from initial")
Common typedefs and tag types for the Cellular Automata module.
Update-scheme aware engine.
Critters reversible CA block rule.
Lattice that adds boundary-aware access on top of a storage.
Placeholder neighbourhood for engines that drive block rules.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
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.
Phase 13 update-scheme aware engine.
Block-based local rules for Aleph::CA (Phase 13).
Cellular automata lattice with pluggable boundary policies.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).
Phase 13 update-scheme strategies for Aleph::CA.