{
  "openapi": "3.1.1",
  "info": {
    "title": "Game of Life \u0026 Cellular Automata Lab API",
    "version": "1.0.0",
    "summary": "Run Life-like rules with RLE patterns, find periods and spaceships, or draw elementary rules.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://prooflinecellularautomata.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Run Life-like rules with RLE patterns, find periods and spaceships, or draw elementary rules.",
        "description": "Run Conway’s Game of Life or any Life-like rule in B/S notation (HighLife, Day \u0026 Night, Seeds …) on an unbounded plane, a torus or a bounded grid. Start from classic patterns (glider, spaceship, pulsar, Gosper gun, R-pentomino, acorn), a seeded random soup, or paste a pattern in RLE or plaintext. The result shows the final generation, the population curve, whether the pattern is a still life, oscillator or spaceship (with period and speed) and the final pattern as RLE. The second mode draws Wolfram’s elementary rules 0–255 as a space-time diagram. Part of the Proofline math notebook.\n\nMethodology:\n- Life-like rules: a dead cell with a neighbour count listed after B is born, a live cell with a count listed after S survives, all others die; the eight Moore neighbours are counted and every cell updates at once. The unbounded plane stores only live cells (a hash set), so gliders can fly away freely.\n- Behaviour: the live cells of every generation, relative to their bounding box (absolute on a torus), are hashed; the first repeat gives the period, and a shift of the bounding box between the two repeats makes the pattern a spaceship with that displacement per period.\n- Elementary rules: the new state of a cell is bit (4·left + 2·centre + right) of the rule number (Wolfram’s numbering).\n- Verified: glider period 4 moving (1, 1); lightweight spaceship period 4 moving 2 cells; Gosper gun gains 5 cells (one glider) every 30 generations; R-pentomino ends with 116 cells at generation 1103 and acorn with 633 after 5206; diehard vanishes at 130; rule 90 rows follow Gould’s sequence; rule 30’s centre column matches OEIS A051023.\n\nRuns stop at 10,000 generations or when the pattern grows too large for one calculation. Bounded grids treat cells beyond the edge as dead, which changes how patterns behave there.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "proofline_cellular_automata",
        "x-owner-app": "proofline",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProoflineCellularAutomataInput"
              },
              "examples": {
                "example1": {
                  "summary": "Glider: a period-4 spaceship",
                  "value": {
                    "preset": "glider",
                    "generations": 40
                  }
                },
                "example2": {
                  "summary": "Gosper glider gun, 120 generations",
                  "value": {
                    "preset": "gosper-gun",
                    "generations": 120
                  }
                },
                "example3": {
                  "summary": "R-pentomino until it settles (1103 generations)",
                  "value": {
                    "preset": "r-pentomino",
                    "generations": 1103
                  }
                },
                "example4": {
                  "summary": "Your RLE pattern under HighLife",
                  "value": {
                    "preset": "custom",
                    "pattern": "#N Replicator\nx = 5, y = 5, rule = B36/S23\n2b3o$bo2bo$o3bo$o2bob$3o!",
                    "rule": "B36/S23",
                    "generations": 48
                  }
                },
                "example5": {
                  "summary": "Random soup on a torus",
                  "value": {
                    "preset": "random",
                    "boundary": "torus",
                    "gridWidth": 64,
                    "gridHeight": 48,
                    "generations": 500,
                    "seed": 7
                  }
                },
                "example6": {
                  "summary": "Elementary rule 30 from one cell",
                  "value": {
                    "mode": "elementary",
                    "ruleNumber": 30,
                    "cells": 201,
                    "steps": 100
                  }
                },
                "example7": {
                  "summary": "Elementary rule 90: the Sierpiński triangle",
                  "value": {
                    "mode": "elementary",
                    "ruleNumber": 90,
                    "cells": 257,
                    "steps": 128
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProoflineCellularAutomataResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ProoflineCellularAutomataInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "Automaton",
            "type": "string",
            "enum": [
              "life",
              "elementary"
            ],
            "default": "life"
          },
          "preset": {
            "title": "Starting pattern (Life)",
            "type": "string",
            "enum": [
              "custom",
              "random",
              "glider",
              "lwss",
              "blinker",
              "pulsar",
              "gosper-gun",
              "r-pentomino",
              "acorn",
              "diehard"
            ],
            "default": "glider"
          },
          "pattern": {
            "title": "Pattern (RLE or plaintext)",
            "description": "RLE as used by Golly and LifeWiki (b dead, o alive, $ new row, ! end; a number repeats), or rows of . and O. Used with “My pattern”.",
            "type": "string",
            "maxLength": 200000,
            "default": ""
          },
          "rule": {
            "title": "Rule (Life)",
            "description": "Empty: the pattern’s own rule or Conway’s B3/S23. Examples: B36/S23 HighLife, B3678/S34678 Day \u0026 Night.",
            "type": "string",
            "maxLength": 30,
            "default": ""
          },
          "boundary": {
            "title": "World (Life)",
            "type": "string",
            "enum": [
              "unbounded",
              "torus",
              "bounded"
            ],
            "default": "unbounded"
          },
          "gridWidth": {
            "title": "Grid width (torus, bounded, random)",
            "type": "integer",
            "minimum": 4,
            "maximum": 1000,
            "default": 64
          },
          "gridHeight": {
            "title": "Grid height (torus, bounded, random)",
            "type": "integer",
            "minimum": 4,
            "maximum": 1000,
            "default": 48
          },
          "generations": {
            "title": "Generations (Life)",
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "default": 100
          },
          "density": {
            "title": "Random density",
            "type": "number",
            "minimum": 0.01,
            "maximum": 0.99,
            "default": 0.3
          },
          "seed": {
            "title": "Random seed",
            "type": "integer",
            "default": 1
          },
          "ruleNumber": {
            "title": "Rule number (elementary)",
            "type": "integer",
            "minimum": 0,
            "maximum": 255,
            "default": 30
          },
          "cells": {
            "title": "Cells per row (elementary)",
            "type": "integer",
            "minimum": 3,
            "maximum": 2001,
            "default": 201
          },
          "steps": {
            "title": "Steps (elementary)",
            "type": "integer",
            "minimum": 1,
            "maximum": 2000,
            "default": 100
          },
          "start": {
            "title": "First row (elementary)",
            "type": "string",
            "enum": [
              "single",
              "random",
              "custom"
            ],
            "default": "single"
          },
          "startRow": {
            "title": "My first row (0 and 1)",
            "type": "string",
            "maxLength": 2001,
            "default": ""
          },
          "wrap": {
            "title": "Row wraps around (elementary)",
            "type": "boolean",
            "default": true
          }
        },
        "required": []
      },
      "ProoflineCellularAutomataResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "mode"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "life",
                  "elementary"
                ]
              },
              "rule": {
                "type": "string"
              },
              "boundary": {
                "type": "string"
              },
              "gridWidth": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "gridHeight": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "preset": {
                "type": "string"
              },
              "patternName": {
                "type": "string"
              },
              "generations": {
                "type": "integer"
              },
              "initialPopulation": {
                "type": "integer"
              },
              "finalPopulation": {
                "type": "integer"
              },
              "minPopulation": {
                "type": "integer"
              },
              "maxPopulation": {
                "type": "integer"
              },
              "population": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              },
              "boundingBox": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "x",
                  "y",
                  "width",
                  "height"
                ],
                "properties": {
                  "x": {
                    "type": "integer"
                  },
                  "y": {
                    "type": "integer"
                  },
                  "width": {
                    "type": "integer"
                  },
                  "height": {
                    "type": "integer"
                  }
                }
              },
              "behaviour": {
                "type": "string",
                "enum": [
                  "dies out",
                  "still life",
                  "oscillator",
                  "spaceship",
                  "none found"
                ]
              },
              "period": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "displacement": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "dx",
                  "dy"
                ],
                "properties": {
                  "dx": {
                    "type": "integer"
                  },
                  "dy": {
                    "type": "integer"
                  }
                }
              },
              "firstRepeat": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "rle": {
                "type": "string"
              },
              "ruleNumber": {
                "type": "integer"
              },
              "wolframCode": {
                "type": "string"
              },
              "cells": {
                "type": "integer"
              },
              "steps": {
                "type": "integer"
              },
              "wrap": {
                "type": "boolean"
              },
              "start": {
                "type": "string"
              },
              "liveCounts": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              },
              "centerColumn": {
                "type": "string"
              },
              "finalDensity": {
                "type": "number"
              },
              "cycle": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "start",
                  "period"
                ],
                "properties": {
                  "start": {
                    "type": "integer"
                  },
                  "period": {
                    "type": "integer"
                  }
                }
              },
              "table": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "neighbourhood",
                    "next"
                  ],
                  "properties": {
                    "neighbourhood": {
                      "type": "string"
                    },
                    "next": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}