A tiny, very shareable demo in the spirit of examples/reaction_diffusion.py and examples/train_neural_ca.py: Conway's Game of Life with every generation as one on-engine forward pass.
Approach:
- The neighbor count is a fixed 3x3 convolution with a center-zero kernel (all ones except the middle).
aneforge/graph.py has af.conv / conv2d (see line ~455) -- use it with a constant weight, pad=1 (wrap-around is optional; zero-pad is fine for a first version).
- The birth/survival rule is elementwise: a cell is alive next step iff
(neighbors == 3) or (alive and neighbors == 2). Build it from select / maximum / clip (all in graph.py) or from arithmetic on the boolean-ish masks -- no host loop over cells.
- Roll out N steps, dispatching the step graph each generation, and render frames to an animated webp with PIL exactly like
reaction_diffusion.py does (from PIL import Image). Seed with a glider gun or a random field.
Deliverable: examples/game_of_life.py (self-contained, one file, module docstring saying what it shows), plus a one-line entry in examples/README.md. Keep the output asset small.
Testing: compare the first few generations against a trivial numpy Life reference to confirm the on-engine rule matches, then let it run. Requires any Apple Silicon Mac. A great newcomer demo -- follow reaction_diffusion.py as the template for the render loop and _common.py for env setup.
A tiny, very shareable demo in the spirit of
examples/reaction_diffusion.pyandexamples/train_neural_ca.py: Conway's Game of Life with every generation as one on-engine forward pass.Approach:
aneforge/graph.pyhasaf.conv/conv2d(see line ~455) -- use it with a constant weight,pad=1(wrap-around is optional; zero-pad is fine for a first version).(neighbors == 3) or (alive and neighbors == 2). Build it fromselect/maximum/clip(all ingraph.py) or from arithmetic on the boolean-ish masks -- no host loop over cells.reaction_diffusion.pydoes (from PIL import Image). Seed with a glider gun or a random field.Deliverable:
examples/game_of_life.py(self-contained, one file, module docstring saying what it shows), plus a one-line entry inexamples/README.md. Keep the output asset small.Testing: compare the first few generations against a trivial numpy Life reference to confirm the on-engine rule matches, then let it run. Requires any Apple Silicon Mac. A great newcomer demo -- follow
reaction_diffusion.pyas the template for the render loop and_common.pyfor env setup.