{
  "openapi": "3.1.1",
  "info": {
    "title": "Pixelpier API",
    "version": "1.0.0",
    "summary": "Deterministic tools for people and AI agents.",
    "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://pixelpier.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/tools": {
      "get": {
        "operationId": "listTools",
        "summary": "Catalog of all tools",
        "responses": {
          "200": {
            "description": "Tool list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/{id}": {
      "get": {
        "operationId": "getTool",
        "summary": "Definition of one tool",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "pixelpier-blockfall-solver",
                "pixelpier-replay-check",
                "tournament-bracket-maker"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/pixelpier-blockfall-solver/calculate": {
      "post": {
        "operationId": "calculatePixelpierBlockfallSolver",
        "summary": "Find the best spot for a falling four-cell piece on any board, with optional lookahead.",
        "description": "Paste a falling-blocks board as rows of “.” and “#”, pick the current piece (I, O, T, S, Z, J or L) and optionally the next one. The solver tries every rotation and column the piece can be dropped into, scores each resulting board by height, holes, transitions and wells, and returns the best placement with the board after it, cleared rows and the runner-up placements. It is the same function that powers the hint and the demo player in Pixelpier’s Blockfall.\n\nMethodology:\n- Pieces use their spawn orientation as rotation 0; rotations 1–3 are quarter turns clockwise inside the piece’s box (4 × 4 for I, 2 × 2 for O, 3 × 3 for the others).\n- Placements: every rotation and column from which the piece can fall straight down from the top of the board. Slides under overhangs and twist moves are not searched.\n- Each placement is scored on the board after it (rows cleared first) with Dellacherie’s features — landing height, eroded piece cells, row and column transitions, holes and well depths — weighted as in El-Ashi (2011), rounded. With a next piece, the score is the average of this placement and the best placement of the next piece after it.\n- “column” is the leftmost column the piece covers and “landingRow” its top row, both counted from 0 at the top-left. Ties go to fewer rotations, then to the left.\n\nA heuristic, not a proof of the optimal move: it looks at most one piece ahead.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "pixelpier_blockfall_solver",
        "x-owner-app": "pixelpier",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PixelpierBlockfallSolverInput"
              },
              "examples": {
                "example1": {
                  "summary": "Long piece into a deep well",
                  "value": {
                    "board": "...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n.........##\n####.######\n####.######\n####.######\n####.######",
                    "piece": "I",
                    "next": "",
                    "alternatives": 5
                  }
                },
                "example2": {
                  "summary": "T piece with the next piece known",
                  "value": {
                    "board": "......\n......\n......\n......\n#..###\n##.###",
                    "piece": "T",
                    "next": "O",
                    "alternatives": 3
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixelpierBlockfallSolverResult"
                }
              }
            }
          },
          "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/tools/pixelpier-replay-check/calculate": {
      "post": {
        "operationId": "calculatePixelpierReplayCheck",
        "summary": "Re-run a Pixelpier replay on the real game engine and check the score it really reaches.",
        "description": "Every Pixelpier game is deterministic: the same seed and the same button presses always give the same game. Paste a replay (exported from the high-score list) and the checker plays it again on the game engine — Blockfall, Rockstorm, Coilrun, Brickwave, Jellyraid, Shellhop, Pearlrun, Pier Rally — and returns the final score, level, lives, play time and a fingerprint of the final game state. Give a claimed score to see whether it matches.\n\nMethodology:\n- The replay is validated (format, game id, rules version, seed, difficulty, start level, inputs as [ticks ≥ 1, mask 0–255] runs, at most one hour of ticks).\n- The game engine is created from the seed and options and stepped once per tick (1/60 s) with the recorded button mask; it stops when the game ends.\n- The engines use seeded random numbers kept in the game state and only exactly rounded arithmetic, so the browser and the server reach the same state; the hash is FNV-1a over the canonical JSON of the final state.\n\nProves what a replay scores, not who played it.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "pixelpier_replay_check",
        "x-owner-app": "pixelpier",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PixelpierReplayCheckInput"
              },
              "examples": {
                "example1": {
                  "summary": "30 seconds of Coilrun",
                  "value": {
                    "replay": "{\"format\":\"pixelpier-replay\",\"version\":1,\"game\":\"coilrun\",\"rules\":1,\"seed\":7,\"difficulty\":\"normal\",\"startLevel\":1,\"inputs\":[[80,0],[1,8],[63,0],[1,2],[55,0],[1,4],[95,0],[1,1],[143,0],[1,4],[23,0],[1,2],[95,0],[1,8],[7,0],[1,2],[47,0],[1,4],[15,0],[1,1],[31,0],[1,8],[7,0],[1,1],[7,0],[1,8],[47,0],[1,1],[79,0],[1,8],[63,0],[1,1],[63,0],[1,4],[95,0],[1,2],[55,0],[1,4],[23,0],[1,2],[39,0],[1,8],[55,0],[1,2],[23,0],[1,8],[39,0],[1,1],[104,0],[1,4],[76,0],[1,2],[153,0],[1,8],[41,0],[1,2],[6,0],[1,8],[27,0],[1,1],[55,0],[1,4],[27,0],[1,1],[6,0],[1,8],[23,0]]}"
                  }
                },
                "example2": {
                  "summary": "Check a claimed score",
                  "value": {
                    "replay": "{\"format\":\"pixelpier-replay\",\"version\":1,\"game\":\"coilrun\",\"rules\":1,\"seed\":7,\"difficulty\":\"normal\",\"startLevel\":1,\"inputs\":[[80,0],[1,8],[63,0],[1,2],[55,0],[1,4],[95,0],[1,1],[143,0],[1,4],[23,0],[1,2],[95,0],[1,8],[7,0],[1,2],[47,0],[1,4],[15,0],[1,1],[31,0],[1,8],[7,0],[1,1],[7,0],[1,8],[47,0],[1,1],[79,0],[1,8],[63,0],[1,1],[63,0],[1,4],[95,0],[1,2],[55,0],[1,4],[23,0],[1,2],[39,0],[1,8],[55,0],[1,2],[23,0],[1,8],[39,0],[1,1],[104,0],[1,4],[76,0],[1,2],[153,0],[1,8],[41,0],[1,2],[6,0],[1,8],[27,0],[1,1],[55,0],[1,4],[27,0],[1,1],[6,0],[1,8],[23,0]]}",
                    "claimedScore": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PixelpierReplayCheckResult"
                }
              }
            }
          },
          "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/tools/tournament-bracket-maker/calculate": {
      "post": {
        "operationId": "calculateTournamentBracketMaker",
        "summary": "Single or double elimination or round robin: seeded brackets, byes, results and downloads.",
        "description": "Paste the entrants (in seed order, or let a seeded random draw decide) and pick single elimination, double elimination or round robin. Get a bracket with standard seeding and byes for the top seeds, a match list, and — as you enter results — winners advancing, standings and the champion. Download the bracket as JSON or CSV to share it.\n\nMethodology:\n- Elimination brackets are padded to the next power of two. Seeds are placed in the standard order (1 v 8, 4 v 5, 2 v 7, 3 v 6 for eight), so the top seeds can only meet late and the byes go to the highest seeds.\n- Double elimination: losers of winners-round 1 meet in losers-round 1; afterwards losers-bracket rounds alternate between taking in the losers of the next winners round (in reversed order on alternate rounds to reduce early rematches) and pairing up survivors. The winners-bracket champion meets the losers-bracket champion in the grand final; if the losers-bracket player wins it, an optional reset match decides.\n- Round robin uses the circle method (Berger tables): with an odd number of players one player rests each round. Standings: 3 points for a win, 1 for a draw, then wins, then name.\n- Results advance the winner (and, in double elimination, drop the loser into the losers bracket). Results naming someone who is not in that match, or for matches whose players are not known yet, are ignored with a warning.\n- A random draw shuffles the entrants with a seeded generator, so the same seed always gives the same bracket. To share a bracket, download the JSON (it contains the input, so it can be re-run via the API) or the CSV match list.",
        "tags": [
          "fun"
        ],
        "x-mcp-tool": "tournament_bracket_maker",
        "x-owner-app": "fieldday",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TournamentBracketMakerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Six players, single elimination, two rounds played",
                  "value": {
                    "title": "Office ping-pong",
                    "entrants": [
                      "Ana",
                      "Ben",
                      "Chloe",
                      "Dev",
                      "Emil",
                      "Fatima"
                    ],
                    "format": "single",
                    "seeding": "listed",
                    "thirdPlace": true,
                    "results": [
                      {
                        "match": "W1-2",
                        "winner": "Dev",
                        "score": "11–8"
                      },
                      {
                        "match": "W1-4",
                        "winner": "Fatima",
                        "score": "11–9"
                      },
                      {
                        "match": "W2-1",
                        "winner": "Ana",
                        "score": "2–1"
                      }
                    ]
                  }
                },
                "example2": {
                  "summary": "Double elimination for 8 teams",
                  "value": {
                    "title": "Pub quiz cup",
                    "entrants": [
                      "Quizzly Bears",
                      "Smarty Pints",
                      "Les Quizerables",
                      "Agatha Quiztie",
                      "The Know-Its",
                      "Trivia Newton-John",
                      "Universally Challenged",
                      "Brainy Bunch"
                    ],
                    "format": "double",
                    "seeding": "listed",
                    "results": [
                      {
                        "match": "W1-1",
                        "winner": "Quizzly Bears"
                      },
                      {
                        "match": "W1-2",
                        "winner": "The Know-Its"
                      }
                    ]
                  }
                },
                "example3": {
                  "summary": "Round robin for five",
                  "value": {
                    "title": "Chess club",
                    "entrants": [
                      "Ivy",
                      "Jon",
                      "Kai",
                      "Lea",
                      "Mo"
                    ],
                    "format": "round-robin",
                    "seeding": "random",
                    "seed": "autumn",
                    "results": [
                      {
                        "match": "R1-1",
                        "winner": "draw"
                      },
                      {
                        "match": "R1-2",
                        "winner": "Kai"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TournamentBracketMakerResult"
                }
              }
            }
          },
          "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/workflows": {
      "get": {
        "operationId": "listWorkflows",
        "summary": "Multi-tool workflows",
        "responses": {
          "200": {
            "description": "Workflow list.",
            "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"
                }
              }
            }
          }
        }
      },
      "PixelpierBlockfallSolverInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "board": {
            "title": "Board (top row first; “.” = empty, “#” = filled)",
            "description": "Width 4–20 cells, height 4–40 rows. Pixelpier’s Blockfall deck is 11 × 21. Any character other than “.” or a space counts as filled.",
            "type": "string",
            "maxLength": 1000,
            "default": "...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n...........\n.........##\n####.######\n####.######\n####.######\n####.######"
          },
          "piece": {
            "title": "Current piece",
            "type": "string",
            "enum": [
              "I",
              "O",
              "T",
              "S",
              "Z",
              "J",
              "L"
            ],
            "default": "I"
          },
          "next": {
            "title": "Next piece (optional lookahead)",
            "type": "string",
            "enum": [
              "",
              "I",
              "O",
              "T",
              "S",
              "Z",
              "J",
              "L"
            ],
            "default": ""
          },
          "alternatives": {
            "title": "Runner-up placements to list",
            "type": "integer",
            "minimum": 0,
            "maximum": 10,
            "default": 5
          }
        },
        "required": []
      },
      "PixelpierBlockfallSolverResult": {
        "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": [
              "width",
              "height",
              "piece",
              "next",
              "placements",
              "best",
              "alternatives",
              "gameOver"
            ],
            "properties": {
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "piece": {
                "type": "string"
              },
              "next": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "placements": {
                "type": "integer"
              },
              "best": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "rotation",
                  "column",
                  "landingRow",
                  "lines",
                  "score",
                  "cells",
                  "board"
                ],
                "properties": {
                  "rotation": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 3
                  },
                  "column": {
                    "type": "integer"
                  },
                  "landingRow": {
                    "type": "integer"
                  },
                  "lines": {
                    "type": "integer"
                  },
                  "score": {
                    "type": "number"
                  },
                  "cells": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      }
                    }
                  },
                  "board": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "alternatives": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "rotation",
                    "column",
                    "landingRow",
                    "lines",
                    "score"
                  ],
                  "properties": {
                    "rotation": {
                      "type": "integer"
                    },
                    "column": {
                      "type": "integer"
                    },
                    "landingRow": {
                      "type": "integer"
                    },
                    "lines": {
                      "type": "integer"
                    },
                    "score": {
                      "type": "number"
                    }
                  }
                }
              },
              "gameOver": {
                "type": "boolean"
              }
            }
          },
          "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"
              }
            }
          }
        }
      },
      "PixelpierReplayCheckInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "replay": {
            "title": "Replay (JSON from Pixelpier)",
            "description": "Format \"pixelpier-replay\" version 1: game, rules, seed, difficulty, startLevel and inputs as runs of [ticks, buttons]. Up to 60 minutes of play.",
            "type": "string",
            "maxLength": 600000,
            "default": "{\"format\":\"pixelpier-replay\",\"version\":1,\"game\":\"coilrun\",\"rules\":1,\"seed\":7,\"difficulty\":\"normal\",\"startLevel\":1,\"inputs\":[[80,0],[1,8],[63,0],[1,2],[55,0],[1,4],[95,0],[1,1],[143,0],[1,4],[23,0],[1,2],[95,0],[1,8],[7,0],[1,2],[47,0],[1,4],[15,0],[1,1],[31,0],[1,8],[7,0],[1,1],[7,0],[1,8],[47,0],[1,1],[79,0],[1,8],[63,0],[1,1],[63,0],[1,4],[95,0],[1,2],[55,0],[1,4],[23,0],[1,2],[39,0],[1,8],[55,0],[1,2],[23,0],[1,8],[39,0],[1,1],[104,0],[1,4],[76,0],[1,2],[153,0],[1,8],[41,0],[1,2],[6,0],[1,8],[27,0],[1,1],[55,0],[1,4],[27,0],[1,1],[6,0],[1,8],[23,0]]}"
          },
          "claimedScore": {
            "title": "Claimed score (optional)",
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000
          }
        },
        "required": []
      },
      "PixelpierReplayCheckResult": {
        "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": [
              "game",
              "name",
              "rules",
              "seed",
              "difficulty",
              "startLevel",
              "ticks",
              "seconds",
              "score",
              "level",
              "lives",
              "over",
              "hash",
              "counters",
              "claimedScore",
              "claimMatches"
            ],
            "properties": {
              "game": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "rules": {
                "type": "integer"
              },
              "seed": {
                "type": "integer"
              },
              "difficulty": {
                "type": "string"
              },
              "startLevel": {
                "type": "integer"
              },
              "ticks": {
                "type": "integer"
              },
              "seconds": {
                "type": "number"
              },
              "score": {
                "type": "integer"
              },
              "level": {
                "type": "integer"
              },
              "lives": {
                "type": "integer"
              },
              "over": {
                "type": "boolean"
              },
              "hash": {
                "type": "string"
              },
              "counters": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              },
              "claimedScore": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "claimMatches": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            }
          },
          "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"
              }
            }
          }
        }
      },
      "TournamentBracketMakerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "title": {
            "title": "Tournament name",
            "type": "string",
            "maxLength": 80,
            "default": "Tournament"
          },
          "entrants": {
            "title": "Entrants (one per line, best seed first)",
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 64
          },
          "format": {
            "title": "Format",
            "type": "string",
            "enum": [
              "single",
              "double",
              "round-robin"
            ],
            "default": "single"
          },
          "seeding": {
            "title": "Seeding",
            "type": "string",
            "enum": [
              "listed",
              "random"
            ],
            "default": "listed"
          },
          "thirdPlace": {
            "title": "Third-place match (single elimination)",
            "type": "boolean",
            "default": false
          },
          "grandFinalReset": {
            "title": "Grand-final reset if the losers-bracket player wins (double elimination)",
            "type": "boolean",
            "default": true
          },
          "results": {
            "title": "Results",
            "description": "Match id from the match list (e.g. W1-2, L1-1, GF-1, R3-2) and the winner’s name. Round robin: write “draw” for a draw.",
            "type": "array",
            "maxItems": 200,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "match": {
                  "title": "Match",
                  "type": "string",
                  "maxLength": 10
                },
                "winner": {
                  "title": "Winner",
                  "type": "string",
                  "maxLength": 40
                },
                "score": {
                  "title": "Score (optional)",
                  "type": "string",
                  "maxLength": 20
                }
              },
              "required": [
                "match",
                "winner"
              ]
            }
          },
          "seed": {
            "title": "Random draw seed (optional)",
            "description": "Only for a random draw. Empty = derived from the entrant list.",
            "type": "string",
            "maxLength": 60
          }
        },
        "required": [
          "entrants"
        ]
      },
      "TournamentBracketMakerResult": {
        "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": [
              "title",
              "format",
              "seed",
              "entrants",
              "bracketSize",
              "byes",
              "matches",
              "nextMatches",
              "champion",
              "standings",
              "completed"
            ],
            "properties": {
              "title": {
                "type": "string"
              },
              "format": {
                "type": "string",
                "enum": [
                  "single",
                  "double",
                  "round-robin"
                ]
              },
              "seed": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "entrants": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "seed",
                    "name"
                  ],
                  "properties": {
                    "seed": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    }
                  }
                }
              },
              "bracketSize": {
                "type": "integer"
              },
              "byes": {
                "type": "integer"
              },
              "matches": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "bracket",
                    "round",
                    "roundName",
                    "a",
                    "b",
                    "aFrom",
                    "bFrom",
                    "winner",
                    "loser",
                    "score",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "bracket": {
                      "type": "string",
                      "enum": [
                        "W",
                        "L",
                        "GF",
                        "3P",
                        "RR"
                      ]
                    },
                    "round": {
                      "type": "integer"
                    },
                    "roundName": {
                      "type": "string"
                    },
                    "a": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "b": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "aFrom": {
                      "type": "string"
                    },
                    "bFrom": {
                      "type": "string"
                    },
                    "winner": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "loser": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "score": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "ready",
                        "done",
                        "bye",
                        "not-needed",
                        "draw"
                      ]
                    }
                  }
                }
              },
              "nextMatches": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Ids of matches whose players are known but that have no result yet."
              },
              "champion": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "standings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "rank",
                    "name",
                    "played",
                    "won",
                    "drawn",
                    "lost",
                    "points"
                  ],
                  "properties": {
                    "rank": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "played": {
                      "type": "integer"
                    },
                    "won": {
                      "type": "integer"
                    },
                    "drawn": {
                      "type": "integer"
                    },
                    "lost": {
                      "type": "integer"
                    },
                    "points": {
                      "type": "integer"
                    }
                  }
                }
              },
              "completed": {
                "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"
              }
            }
          }
        }
      }
    }
  }
}