68 static constexpr int gun[][2] = {
69 {0, 24}, {1, 22}, {1, 24}, {2, 12}, {2, 13}, {2, 20}, {2, 21}, {2, 34},
70 {2, 35}, {3, 11}, {3, 15}, {3, 20}, {3, 21}, {3, 34}, {3, 35}, {4, 0},
71 {4, 1}, {4, 10}, {4, 16}, {4, 20}, {4, 21}, {5, 0}, {5, 1}, {5, 10},
72 {5, 14}, {5, 16}, {5, 17}, {5, 22}, {5, 24}, {6, 10}, {6, 16}, {6, 24},
73 {7, 11}, {7, 15}, {8, 12}, {8, 13},
75 for (
const auto &p :
gun)
81 std::size_t alive = 0;
82 for (std::size_t i = 0; i <
lat.size(0); ++i)
83 for (std::size_t j = 0; j <
lat.size(1); ++j)
84 if (
lat.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}) != 0)
87 std::printf(
"\nStep %4zu alive=%zu\n", step, alive);
91 for (std::size_t i = 0; i <
lat.size(0); ++i)
93 for (std::size_t j = 0; j <
lat.size(1); ++j)
95 lat.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}) != 0
106 for (std::size_t i = 0; i < a.
size(0); ++i)
107 for (std::size_t j = 0; j < a.
size(1); ++j)
108 if (a.
at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)})
109 != b.
at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}))
118 constexpr std::size_t
rows = 60;
119 constexpr std::size_t
cols = 80;
120 constexpr std::size_t
steps = 240;
125 std::printf(
"Aleph::CA Phase-5 example: parallel Game of Life with Gosper's gun\n");
126 std::printf(
"Grid %zux%zu, toroidal, %zu steps, hardware_concurrency=%u\n",
130 static_cast<unsigned>(std::thread::hardware_concurrency()));
135 cfg.min_parallel_cells = 0;
143 for (std::size_t s = 30; s <=
steps; s += 30)
157 std::printf(
"\n*** parallel and sequential frames diverged ***\n");
160 std::printf(
"\nParallel run matched the sequential reference frame "
161 "(%zu cells / step).\n",
162 static_cast<std::size_t
>(
rows) *
cols);
Convenience builders for the Phase 3 synchronous engine.
Lattice that adds boundary-aware access on top of a storage.
const extents_type & extents() const noexcept
ca_size_t size() const noexcept
state_type at(const coord_type &c) const
Strict access: throws if c is out of range.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Parallel synchronous double-buffered engine.
Synchronous double-buffered engine.
void run(const std::size_t steps)
Run several synchronous steps.
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.
bool frames_equal(const Lattice &a, const Lattice &b)
Main namespace for Aleph-w library functions.
Configuration for Parallel_Synchronous_Engine.
std::size_t num_partitions
Number of partitions per step.
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.
Parallel synchronous engine for cellular automata (Phase 5).
Rule mechanisms for Aleph::CA.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).