{
  "openapi": "3.1.1",
  "info": {
    "title": "Pinball Score Simulator API",
    "version": "1.0.0",
    "summary": "Play whole Pinquest pinball games with a bot: score spread, missions finished and a ball heat map.",
    "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://pinquestscoresim.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Play whole Pinquest pinball games with a bot: score spread, missions finished and a ball heat map.",
        "description": "Plays up to 20 complete games of a Pinquest table — built-in or your own JSON — with the autoplay bot and the real physics and rules, then reports the score spread, game length, which missions and wizard modes were finished, the busiest switches and a heat map of where the ball spends its time. Useful to balance a table’s scoring.\n\nMethodology:\n- Each game starts with the table’s rules (balls, ball save, missions, wizard) and is played by the autoplay bot with the same deterministic physics as the game: fixed 1/240 s steps, swept-circle collisions, flipper surface speed transferred to the ball.\n- Scores include switch scores, mission rewards, jackpots and the end-of-ball bonus × bonus multiplier, exactly as the game counts them. A game stops after 15 simulated minutes.\n- The heat map samples the ball position on the main playfield every 1/15 s in a 10 × 20 grid; 100 = the busiest cell.\n- The same table, seed and settings always give the same result; change the seed for another set of games.\n\nBot scores show how a table plays and pays relative to other tables — they are not a prediction of human scores.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "pinquest_score_sim",
        "x-owner-app": "pinquest",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PinquestScoreSimInput"
              },
              "examples": {
                "example1": {
                  "summary": "Five games on Zombie Night",
                  "value": {
                    "table": "zombie-night",
                    "tableJson": "",
                    "games": 5,
                    "balls": 3,
                    "seed": 1
                  }
                },
                "example2": {
                  "summary": "Three one-ball games on the Witch's castle",
                  "value": {
                    "table": "witch-castle",
                    "tableJson": "",
                    "games": 3,
                    "balls": 1,
                    "seed": 4
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PinquestScoreSimResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "PinquestScoreSimInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "table": {
            "title": "Table",
            "type": "string",
            "enum": [
              "witch-castle",
              "zombie-night",
              "pirate-treasure",
              "space-station",
              "dragon-lair",
              "haunted-circus",
              "deep-sea",
              "jungle-temple",
              "steampunk-airship",
              "ninja-dojo",
              "wild-west-heist",
              "alien-invasion",
              "dinosaur-island",
              "candy-kingdom",
              "robot-factory",
              "viking-saga",
              "egyptian-tomb",
              "cyber-city",
              "fairy-forest",
              "volcano-forge",
              "arctic-expedition",
              "monster-carnival",
              "superhero-city",
              "detective-noir",
              "mad-science-lab",
              "samurai-storm",
              "moon-base",
              "wizard-school",
              "kaiju-attack",
              "atlantis",
              "sky-islands",
              "ghost-train"
            ],
            "default": "witch-castle"
          },
          "tableJson": {
            "title": "Your own table (Pinquest table JSON, optional — replaces the table above)",
            "description": "The format is described in the Pinquest table spec: elements (walls, flippers, bumpers, ramps …) in table units (20 × 40), lights and rules with missions.",
            "type": "string",
            "maxLength": 200000,
            "default": ""
          },
          "games": {
            "title": "Games",
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "default": 5
          },
          "balls": {
            "title": "Balls per game",
            "type": "integer",
            "minimum": 1,
            "maximum": 5,
            "default": 3
          },
          "seed": {
            "title": "Random seed of the bot",
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000,
            "default": 1
          }
        },
        "required": []
      },
      "PinquestScoreSimResult": {
        "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": [
              "table",
              "games",
              "balls",
              "scores",
              "seconds",
              "perGame",
              "missions",
              "wizardCompletedIn",
              "topSwitches",
              "heat"
            ],
            "properties": {
              "table": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "id",
                  "title"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  }
                }
              },
              "games": {
                "type": "integer"
              },
              "balls": {
                "type": "integer"
              },
              "scores": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "min",
                  "median",
                  "mean",
                  "max"
                ],
                "properties": {
                  "min": {
                    "type": "integer"
                  },
                  "median": {
                    "type": "integer"
                  },
                  "mean": {
                    "type": "integer"
                  },
                  "max": {
                    "type": "integer"
                  }
                }
              },
              "seconds": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "mean",
                  "max"
                ],
                "properties": {
                  "mean": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  }
                }
              },
              "perGame": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "game",
                    "score",
                    "seconds",
                    "missionsDone",
                    "multiballs",
                    "ballSaves",
                    "drains"
                  ],
                  "properties": {
                    "game": {
                      "type": "integer"
                    },
                    "score": {
                      "type": "integer"
                    },
                    "seconds": {
                      "type": "number"
                    },
                    "missionsDone": {
                      "type": "integer"
                    },
                    "multiballs": {
                      "type": "integer"
                    },
                    "ballSaves": {
                      "type": "integer"
                    },
                    "drains": {
                      "type": "integer"
                    }
                  }
                }
              },
              "missions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "title",
                    "completedIn"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "completedIn": {
                      "type": "integer"
                    }
                  }
                }
              },
              "wizardCompletedIn": {
                "type": "integer"
              },
              "topSwitches": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "event",
                    "perGame"
                  ],
                  "properties": {
                    "event": {
                      "type": "string"
                    },
                    "perGame": {
                      "type": "number"
                    }
                  }
                }
              },
              "heat": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "description": "10 × 20 cells (rows from the top), 0–100 = share of time relative to the busiest cell."
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}