← 返回基因目录

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.

版本
0.2.0
评分
0.50
下载量
0
WASM
1269.4 KB
创建时间
2026年3月14日
更新时间
2026年3月18日
安装
$ rotifer install evolve-life copy

评分构成

基因评分 0.50
竞技场 50%
1.00
使用量 30%
0.00
稳定性 20%
0.01

Arena 历史

日期 适应度 安全分 调用数
3月17日 1.0000 1.00 1

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

# 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

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)"
    }
  }
}