76 constexpr std::uint64_t
SEED = 0xBEEFCAFE123456ULL;
79 inline std::uint64_t
next(std::uint64_t &s)
84 return s * 0x2545F4914F6CDD1DULL;
90 std::uint64_t s =
SEED;
93 lat.set({ i, j }, (
next(s) & 0xF) == 0 ? 1 : 0);
96 template <
typename A,
typename B>
105 if (a.at({ i, j }) != b.at({ i, j }))
111 template <
typename L>
112 std::size_t population(
const L &
lat)
117 pop +=
static_cast<std::size_t
>(
lat.at({ i, j }) != 0);
124 double steps_per_sec;
125 std::size_t final_population;
128 template <
typename Engine>
132 const auto t0 = std::chrono::steady_clock::now();
134 const auto t1 = std::chrono::steady_clock::now();
136 = std::chrono::duration<double, std::milli>(
t1 -
t0).count();
142 unsigned long long &
out)
144 if (text ==
nullptr or *text ==
'\0' or *text ==
'-')
146 std::cerr <<
"ERROR: " << name <<
" must be a positive integer.\n";
152 const unsigned long long value = std::strtoull(text, &end, 10);
155 std::cerr <<
"ERROR: " << name <<
" must be a positive integer; got '"
167 std::size_t
steps = 50;
170 unsigned long long parsed = 0;
172 or parsed >
static_cast<unsigned long long>(std::numeric_limits<ca_size_t>::max()))
174 if (
parsed >
static_cast<unsigned long long>(std::numeric_limits<ca_size_t>::max()))
175 std::cerr <<
"ERROR: size is too large for ca_size_t.\n";
182 unsigned long long parsed = 0;
184 or parsed >
static_cast<unsigned long long>(std::numeric_limits<std::size_t>::max()))
186 if (
parsed >
static_cast<unsigned long long>(std::numeric_limits<std::size_t>::max()))
187 std::cerr <<
"ERROR: steps is too large for std::size_t.\n";
202 std::cout <<
"GoL " <<
size <<
"x" <<
size <<
" for " <<
steps
203 <<
" steps (toroidal).\n";
218 std::cout << std::fixed << std::setprecision(2);
220 std::cout <<
"Phase 3 Lattice : "
223 <<
"population=" <<
classic_res.final_population <<
'\n';
226 std::cout <<
"Phase 4 Ghost_Lattice : "
227 << std::setw(9) <<
ghost_res.wall_ms <<
" ms ("
228 <<
ghost_res.steps_per_sec <<
" steps/s) "
229 <<
"population=" <<
ghost_res.final_population <<
'\n';
233 std::cout <<
"Speedup : " <<
speedup <<
"x\n";
237 std::cerr <<
"ERROR: final frames diverge — halo refresh is broken.\n";
240 std::cout <<
"Final frames bit-identical: OK\n";
size_t size_t int32_t value
size_t size_t int32_t * out
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.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
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().
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.
size_t size(Node *root) noexcept
void next()
Advance all underlying iterators (bounds-checked).
The lattice wraps around on every axis.
Synchronous double-buffered engine for cellular automata.
Ghost-layer lattice for high-performance boundary handling.
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).