58 template <
typename State>
61 constexpr State threshold = 4;
63 if (result >= threshold)
65 for (
const auto &n :
nh)
73void render(
const Grid &g, std::ostream &
os)
75 static const std::array<const char *, 5>
glyphs = {
" .",
" :",
" +",
" #",
"##"};
80 const auto v = g.at({
static_cast<ca_index_t>(i),
82 const std::size_t idx = v < 0 ? 0 : (v > 4 ? 4 :
static_cast<std::size_t
>(v));
94 if (g.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}) >= 4)
118 std::size_t
drops = 80;
123 drops =
static_cast<std::size_t
>(std::stoul(
argv[1]));
127 catch (
const std::invalid_argument &)
129 std::cerr <<
"Invalid argument: expected non-negative integers for [drops] [side]\n";
132 catch (
const std::out_of_range &)
134 std::cerr <<
"Argument out of range for [drops] [side]\n";
139 std::cerr <<
"Invalid side: must be a positive integer\n";
147 std::cout <<
"BTW Sandpile — " <<
side <<
"×" <<
side <<
", " <<
drops
148 <<
" drops at the centre\n\n";
151 for (std::size_t
k = 0;
k <
drops; ++
k)
161 Grid pre =
engine.frame();
173 std::cout <<
"drop " <<
k + 1 <<
"/" <<
drops
174 <<
" — avalanche size " <<
aval
176 <<
", " <<
sweeps <<
" sweeps)\n";
179 std::cout <<
"\nFinal frame:\n\n";
181 std::cout <<
"\nAverage avalanche size: "
Common typedefs and tag types for the Cellular Automata module.
Update-scheme aware engine.
Lattice that adds boundary-aware access on top of a storage.
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().
std::span< const T > Neighbor_View
Read-only view over a contiguous range of neighbour values.
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
std::array< ca_index_t, N > Coord_Vec
Default coordinate vector.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
Out-of-range neighbours behave as if the lattice ended.
In-place sequential update (no double buffer).
Phase 13 update-scheme aware engine.
Cellular automata lattice with pluggable boundary policies.
Neighborhoods catalogue for Aleph::CA.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).
Phase 13 update-scheme strategies for Aleph::CA.