Skip to main content

Module rules

Module rules 

Source
Expand description

The voxel system’s rules: a 3D automaton in the Generations sense, and the closed roster of named ones a preset lists in [voxel] rules (ADR-0268).

A rule is a pair of masks over the live-neighbour count — bit k of birth set means a dead cell with k live neighbours is born, bit k of survive that a live one with k stays live — a count of states, and a neighbourhood. A cell is dead (0), live (1), or in one of the decay stages 2..states; a live cell that does not survive enters the first decay stage, a decaying cell advances one stage a generation and falls back to dead past the last, and only a live cell counts as a neighbour. With states = 2 there are no decay stages, and the rule is a plain 3D life-like one.

The masks are integers end to end. A Moore count reaches 26, so a mask is 27 bits, past what an f32 holds exactly; that is why a rule is chosen from a list by a held index rather than bound as a mask (ADR-0268).

Structs§

Rule
One compiled rule, as the step shader reads it.
RuleList
A preset’s rule list, compiled: one to MAX_RULES rules in a fixed array, so the config stays Copy and nothing per frame allocates.

Enums§

Neighbourhood
Which cells count as a cell’s neighbours.
RosterRule
The closed roster of named rules. Each entry’s notation in the comment is survive/birth/states/neighbourhood, as the 3D automaton catalogues write it; every one is held by every_roster_rule_lives_from_its_own_seed to a live fraction strictly inside (0, 0.9) at generations 100 and 400.

Constants§

DEFAULT_RULE
The rule an absent [voxel] rules key means.
MAX_RULES
The most rules one [voxel] rules list may hold.
MAX_STATES
The most states a rule may hold: dead, live and 253 decay stages, so a state fits the 8 bits the state texel gives it.