66Lat make_random_seed(std::size_t n, std::uint32_t
seed,
double density)
70 std::bernoulli_distribution flip(
density);
71 for (std::size_t i = 0; i < n; ++i)
72 for (std::size_t j = 0; j < n; ++j)
73 lat.set({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)},
82 std::printf(
"Aleph::CA Phase-7 example: full observability pipeline\n");
83 std::printf(
"------------------------------------------------------\n");
86 Lat random_seed = make_random_seed(64, 0xCAFEu, 0.4);
97 comp(dens, act, ent, det, samp);
103 std::printf(
"\nRandom GoL 64x64, 200 steps\n");
104 std::printf(
" density samples : %zu\n", dens.
size());
105 std::printf(
" activity samples : %zu\n", act.
size());
106 std::printf(
" entropy samples : %zu\n", ent.
size());
107 std::printf(
" snapshot count : %zu\n", samp.
size());
108 std::printf(
" density (initial) : %.4f\n", dens.
density_at(0));
109 std::printf(
" density (final) : %.4f\n",
112 double avg_density = 0.0;
113 for (std::size_t i = dens.
size() - 50; i < dens.
size(); ++i)
116 std::printf(
" density (last-50 avg) : %.4f\n", avg_density);
120 double avg_act = 0.0;
122 avg_act +=
static_cast<double>(a);
123 avg_act /=
static_cast<double>(act.
size());
124 std::printf(
" activity (avg) : %.2f cells/step\n", avg_act);
127 std::printf(
" entropy (final) : %.4f nats\n",
130 std::printf(
" short cycle detected : length=%zu starting at step=%zu\n",
133 std::printf(
" short cycle detected : none within window=%zu\n",
137 Lat blinker({5, 5}, 0);
138 blinker.set({2, 1}, 1);
139 blinker.set({2, 2}, 1);
140 blinker.set({2, 3}, 1);
151 std::printf(
"\nBlinker reference run (8 steps)\n");
152 std::printf(
" activity per step :");
154 std::printf(
" %zu", a);
156 std::printf(
" cycle length : %zu\n",
Convenience builders for the Phase 3 synchronous engine.
Free metric helpers for cellular automata frames.
Phase-7 observability layer for cellular automata engines.
Common typedefs and tag types for the Cellular Automata module.
T & get_last()
Return a modifiable reference to the last element.
Records the number of cells that changed across each step.
const Array< ca_size_t > & activity() const noexcept
Return the activity time series.
std::size_t size() const noexcept
Return the number of recorded steps.
Variadic adaptor that fan-outs notifications to many observers.
Records the count of cells in tracked_state per step.
double density_at(const std::size_t i) const
Return density at a recorded sample.
std::size_t size() const noexcept
Return the number of recorded samples.
Records the Shannon entropy of the state distribution.
std::size_t size() const noexcept
Return the number of entropy samples.
const Array< double > & entropy() const noexcept
Return the entropy time series.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Snapshots the lattice every period steps.
std::size_t size() const noexcept
Return the number of stored snapshots.
Detects fixed points and short cycles via frame hashing.
std::size_t buffered_hashes() const noexcept
Return the number of buffered hashes.
std::optional< std::size_t > cycle_start() const noexcept
Return the cycle start step.
bool cycle_detected() const noexcept
Return whether a cycle has been detected.
std::optional< std::size_t > cycle_length() const noexcept
Return the detected cycle length.
Synchronous double-buffered engine.
void attach_observer(Engine &engine, Observer &observer)
Plug an observer into an engine's pre/post-step hooks.
constexpr Game_Of_Life_Rule make_game_of_life_rule() noexcept
Build the canonical Game of Life rule.
double density(const Lattice &lat, const typename Lattice::state_type &s)
Main namespace for Aleph-w library functions.
The lattice wraps around on every axis.
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).