42std::size_t parse_steps(
const char *text,
const std::size_t fallback)
47 const unsigned long value = std::strtoul(text, &end, 10);
48 if (end == text or *end !=
'\0' or
value == 0
49 or
value > std::numeric_limits<std::size_t>::max())
51 return static_cast<std::size_t
>(
value);
57 const std::vector<std::pair<int, int>> &cells)
61 for (
const auto &[dr, dc] : cells)
66int main(
int argc,
char **argv)
68 const std::size_t
steps = argc >= 2 ? parse_steps(argv[1], 400) : 400;
70 Grid grid({48, 80}, 0);
71 stamp(grid, 20, 30, {{0, 1}, {1, 2}, {2, 0}, {2, 1}, {2, 2}});
72 stamp(grid, 10, 12, {{0, -1}, {0, 0}, {0, 1}});
78 opts.
title =
"Aleph::CA Game of Life";
81 for (std::size_t i = 0; i <=
steps; ++i)
89 std::cout <<
"Ran " <<
steps <<
" Game-of-Life steps";
90 if (not viewer.active())
91 std::cout <<
" (viewer inactive; DISPLAY was probably unavailable)";
size_t size_t int32_t value
Convenience builders for the Phase 3 synchronous engine.
Optional live X11 viewer sink for CA simulations.
Lattice that adds boundary-aware access on top of a storage.
void accept(const std::size_t step, const Lattice &frame)
Draw one frame, or no-op when disabled/headless.
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
Game_Of_Life_Engine make_gol_engine(ca_size_t rows, ca_size_t cols)
Build a Conway's Game of Life engine of the given shape.
Default binary RGB mapper.
The lattice wraps around on every axis.
Options for the live X11 viewer.
unsigned delay_ms
sleep after each drawn frame
unsigned cell_size
pixels per CA cell
std::string title
window title
Cellular automata lattice with pluggable boundary policies.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).