23#include <gtest/gtest.h>
34 std::vector<std::size_t> samples;
37 samples.push_back(
size);
51 for (std::size_t i = 0; i < 2000; ++i)
52 if (
sandpile.drop_random().size != 0)
62 constexpr int a =
static_cast<int>(Schelling_Cell::TYPE_A);
63 constexpr int b =
static_cast<int>(Schelling_Cell::TYPE_B);
64 constexpr int empty =
static_cast<int>(Schelling_Cell::EMPTY);
65 Grid frame({20, 20}, a);
67 for (
ca_size_t column = frame.size(1) / 2; column < frame.size(1); ++column)
76 constexpr int tree =
static_cast<int>(Forest_Cell::TREE);
77 constexpr int burning =
static_cast<int>(Forest_Cell::BURNING);
78 constexpr int empty =
static_cast<int>(Forest_Cell::EMPTY);
79 Grid frame({9, 9}, tree);
80 frame.set({4, 4}, burning);
88 if (
engine.frame().at({static_cast<ca_index_t>(row),
89 static_cast<ca_index_t>(column)}) == burning)
99 std::ostringstream lhs(std::ios::binary);
100 std::ostringstream rhs(std::ios::binary);
103 std::istringstream
lhs_in(lhs.str(), std::ios::binary);
104 std::istringstream
rhs_in(rhs.str(), std::ios::binary);
Internal helpers shared by the cellular-automata reproductions.
Forest-fire rule (Drossel & Schwabl, 1992).
Hashlife engine for outer-totalistic binary cellular automata.
std::uint64_t population() const noexcept
Number of alive cells.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Deterministic open-boundary Bak-Tang-Wiesenfeld sandpile.
Synchronous double-buffered engine.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
RGB8 gray_scott_rgb(const Gray_Scott_Cell &cell)
Convert one Gray-Scott state to an RGB colour.
Linear_Fit fit_log_log_histogram(const std::vector< std::size_t > &samples, const std::size_t min_value, const std::size_t max_value, const std::size_t bins, const double sample_weight_power=0.0)
Fit a power-law exponent from logarithmically binned samples.
void for_each_gosper_gun_cell(F &&visitor, const std::int64_t offset_x=0, const std::int64_t offset_y=0)
Visit every live coordinate in the canonical Gosper gun.
constexpr std::array< Gray_Scott_Preset, 3 > gray_scott_presets
Canonical visual presets used by the weekly Gray-Scott reproduction.
Native_Png decode_native_png(std::istream &in)
Decode a PNG emitted by Aleph::CA::write_png.
Gray_Scott_Lattice run_gray_scott(const Gray_Scott_Preset &preset, const ca_size_t side, const std::size_t steps, const std::uint64_t master_seed)
Run one Gray-Scott preset from the shared deterministic seed.
double morans_i_binary(const Lattice &frame, const typename Lattice::state_type empty_state, const typename Lattice::state_type type_a, const typename Lattice::state_type type_b)
Compute Moran's I for two occupied Schelling cell types.
double mean_channel_difference(const Native_Png &lhs, const Native_Png &rhs)
Compute normalized mean absolute per-channel PNG difference.
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.
void write_png(std::ostream &out, const Lattice &frame, Mapper &&mapper)
Write a rank-2 frame as an 8-bit RGB PNG image.
size_t size(Node *root) noexcept
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
Least-squares result for a log-log histogram.
double slope
fitted exponent.
double r_squared
coefficient of determination.
static constexpr bool requires_double_buffer
Operates in place, no second buffer needed.
The lattice wraps around on every axis.
Hashlife engine for outer-totalistic binary cellular automata.
Reproducible stochastic CA rules (Phase 8).