72namespace fs = std::filesystem;
80template <
typename Lattice,
typename Mapper>
83 std::ofstream
out(path, std::ios::binary);
86 std::cerr <<
"warning: failed writing " << path <<
'\n';
93 std::mt19937
rng(0xA1E90000u ^
static_cast<std::uint32_t
>(
94 std::hash<std::string>{}(key)));
95 std::uniform_real_distribution<double> u(0.0, 1.0);
99 g.set({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)},
116 [on,
off](
int v) { return v != 0 ? on : off; });
117 std::cout <<
" " << name <<
".png (" <<
side <<
"x" <<
side <<
", "
118 <<
steps <<
" steps)\n";
134 img.set({static_cast<ca_index_t>(t), static_cast<ca_index_t>(x)},
135 eng.frame().at({static_cast<ca_index_t>(x)}));
140 const std::string name =
"wolfram_" + std::to_string(
rule_no);
142 [on,
off](
int v) {
return v != 0 ? on :
off; });
143 std::cout <<
" " << name <<
".png (" << width <<
"x" <<
steps
151 const fs::path
out_dir =
argc >= 2 ? fs::path(
argv[1]) : fs::path(
"docs/gallery");
152 fs::create_directories(
out_dir);
154 std::cout <<
"Rendering gallery into " <<
out_dir <<
"\n";
157 std::cout <<
"Life-like rules:\n";
160 [](
int s, std::size_t n) {
return (n == 3
or (s != 0
and n == 2)) ? 1 : 0; },
161 96, 80, 0.30,
RGB8{120, 220, 140});
164 [](
int s, std::size_t n)
165 {
return ((n == 3
or n == 6)
or (s != 0
and n == 2)
or (s != 0
and n == 3)) ? 1 : 0; },
166 96, 80, 0.30,
RGB8{240, 180, 90});
169 [](
int s, std::size_t n)
171 const bool birth = (n == 3
or n == 6
or n == 7
or n == 8);
175 96, 64, 0.45,
RGB8{150, 180, 250});
178 [](
int s, std::size_t n) {
return (s == 0
and n == 2) ? 1 : 0; },
179 96, 24, 0.06,
RGB8{250, 120, 120});
182 [](
int s, std::size_t n)
187 96, 90, 0.18,
RGB8{200, 160, 250});
190 [](
int s, std::size_t n)
192 const bool birth = (n == 3
or n == 6);
196 96, 80, 0.30,
RGB8{120, 210, 230});
199 [](
int, std::size_t n) {
return (n % 2 == 1) ? 1 : 0; },
200 96, 40, 0.004,
RGB8{240, 210, 120});
203 [](
int s, std::size_t n) {
return ((s == 0
and n == 3)
or s != 0) ? 1 : 0; },
204 96, 50, 0.06,
RGB8{170, 230, 160});
207 std::cout <<
"Wolfram elementary rules:\n";
218 std::cout <<
"Done.\n";
size_t size_t int32_t * out
Convenience builders for the Phase 3 synchronous engine.
File-format readers and writers for cellular-automata frames.
Dependency-free PNG frame sink for cellular automata.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Rule whose next state depends on (current, alive_count).
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().
Wolfram_1D_Engine make_wolfram_engine(std::uint8_t rule_no, ca_size_t width)
Build a 1D elementary Wolfram engine of the given width.
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
double density(const Lattice &lat, const typename Lattice::state_type &s)
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.
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.
RGB byte triplet used by PPM exporters.
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).