← Back to Gene Catalog

evolve-life

Native evolve.life

Conway's Game of Life simulator. Computes cellular automaton evolution from an initial grid state over N generations. Supports preset patterns (glider, pulsar, random) and custom grids. Pure computation — ideal Native Gene benchmark.

README

# evolve.life

Conway's Game of Life simulator — a pure-computation Native Gene for the Rotifer Protocol.

## Why

The Game of Life is the quintessential cellular automaton: dead-simple rules produce emergent complexity. It maps perfectly to Rotifer's biological metaphor — cells live, die, and evolve through generations, just like Genes in the Arena.

As a **Native Gene**, `evolve.life` performs zero I/O. It compiles to sandboxed WASM and runs deterministically, making it an ideal benchmark for IR compilation, Arena fitness scoring, and cross-Binding portability.

## Usage

```bash
# Run with a preset pattern
rotifer run evolve.life --input '{"preset": "r-pentomino", "generations": 500}'

# Benchmark: 512x512 grid, 1000 generations
rotifer run evolve.life --input '{"width": 512, "height": 512, "generations": 1000, "preset": "random", "seed": 7}'

# Custom rule (HighLife: B36/S23)
rotifer run evolve.life --input '{"preset": "random", "rule": "B36/S23"}'
```

## Presets

| Preset | Type | Description |
|--------|------|-------------|
| `glider` | Spaceship | Moves diagonally, period 4 |
| `blinker` | Oscillator | Period 2, simplest oscillator |
| `beacon` | Oscillator | Period 2, 2x2 block pair |
| `pulsar` | Oscillator | Period 3, highly symmetric |
| `r-pentomino` | Methuselah | 5 cells → 1103 generations to stabilize |
| `random` | Soup | Seeded 35% density fill |

## Output

- `final_grid` — grid state after simulation
- `alive_count` — live cells at end
- `peak_population` — maximum live cells observed
- `stabilized_at` — generation where grid reached equilibrium (-1 if not)
- `extinction` — whether all cells died
- `cells_processed` — total cell evaluations (for benchmarking)
- `ascii_snapshot` — ASCII art of final state (max 80×40)

## Fitness Characteristics

| Metric | Expected |
|--------|----------|
| Success Rate | 1.0 (deterministic, no failure mode) |
| Latency | <50ms for 64×64×100, ~2s for 512×512×1000 |
| Resource Cost | O(w × h × g) memory: O(w × h) |
| Robustness | Handles all edge cases (empty grid, max size, custom rules) |

Phenotype

Input

PropertyType Description
grid array Custom initial grid (2D array of 0s and 1s). Ignored if preset is set.
rule string = B3/S23 Life-like rule in B/S notation (default: B3/S23 for Conway's Life)
seed number Random seed for 'random' preset (deterministic output)
width number = 64 Grid width in cells
height number = 64 Grid height in cells
preset glider | pulsar | blinker | beacon | r-pentomino | random Initial pattern preset. Overrides grid if provided.
generations number = 100 Number of generations to simulate

Output

PropertyType Req Description
extinction boolean Whether all cells died before final generation
final_grid array Grid state after all generations
alive_count number Number of live cells in final grid
stabilized_at number Generation at which the grid stabilized (-1 if not stabilized)
ascii_snapshot string ASCII art of the final grid state (max 80x40)
cells_processed number Total cell evaluations (width * height * generations_computed)
peak_population number Maximum live cells observed across all generations
generations_computed number Actual number of generations computed (may be less if stabilized/extinct)
Raw JSON Schema

inputSchema

{
  "type": "object",
  "required": [],
  "properties": {
    "grid": {
      "type": "array",
      "items": {
        "type": "array",
        "items": {
          "enum": [
            0,
            1
          ],
          "type": "number"
        }
      },
      "description": "Custom initial grid (2D array of 0s and 1s). Ignored if preset is set."
    },
    "rule": {
      "type": "string",
      "default": "B3/S23",
      "description": "Life-like rule in B/S notation (default: B3/S23 for Conway's Life)"
    },
    "seed": {
      "type": "number",
      "description": "Random seed for 'random' preset (deterministic output)"
    },
    "width": {
      "type": "number",
      "default": 64,
      "maximum": 512,
      "minimum": 4,
      "description": "Grid width in cells"
    },
    "height": {
      "type": "number",
      "default": 64,
      "maximum": 512,
      "minimum": 4,
      "description": "Grid height in cells"
    },
    "preset": {
      "enum": [
        "glider",
        "pulsar",
        "blinker",
        "beacon",
        "r-pentomino",
        "random"
      ],
      "type": "string",
      "description": "Initial pattern preset. Overrides grid if provided."
    },
    "generations": {
      "type": "number",
      "default": 100,
      "maximum": 10000,
      "minimum": 1,
      "description": "Number of generations to simulate"
    }
  }
}

outputSchema

{
  "type": "object",
  "required": [
    "final_grid",
    "alive_count",
    "peak_population",
    "stabilized_at",
    "extinction",
    "generations_computed",
    "cells_processed"
  ],
  "properties": {
    "extinction": {
      "type": "boolean",
      "description": "Whether all cells died before final generation"
    },
    "final_grid": {
      "type": "array",
      "items": {
        "type": "array",
        "items": {
          "enum": [
            0,
            1
          ],
          "type": "number"
        }
      },
      "description": "Grid state after all generations"
    },
    "alive_count": {
      "type": "number",
      "description": "Number of live cells in final grid"
    },
    "stabilized_at": {
      "type": "number",
      "description": "Generation at which the grid stabilized (-1 if not stabilized)"
    },
    "ascii_snapshot": {
      "type": "string",
      "description": "ASCII art of the final grid state (max 80x40)"
    },
    "cells_processed": {
      "type": "number",
      "description": "Total cell evaluations (width * height * generations_computed)"
    },
    "peak_population": {
      "type": "number",
      "description": "Maximum live cells observed across all generations"
    },
    "generations_computed": {
      "type": "number",
      "description": "Actual number of generations computed (may be less if stabilized/extinct)"
    }
  }
}

Arena History

Date Fitness Safety Calls
Mar 17 1.0000 1.00 1