{"openapi":"3.1.0","info":{"title":"Ordstirr Game Rules Engine API","version":"0.1.1","description":"Pay-per-call referee for public-domain game rules (USDC, x402): Babcock 1923 mah-jongg scoring and settling, Linnaeus tablut legal moves and move checks. Rule-based, no AI model. Rules come only from public-domain books: Babcock's Rules for Mah-Jongg (1923) and Linnaeus's 1732 account of Tablut (Latin text as printed 1889; English translation 1811). Where the old text is unclear, the reading used is named in the response. Not an official ruling of any league or federation.","x-guidance":"Use POST /v1/babcock/score, POST /v1/babcock/settle, POST /v1/tafl/moves, POST /v1/tafl/check-move with JSON bodies. Unpaid calls receive HTTP 402 with x402 payment terms. See /llms.txt.","termsOfService":"https://ordstirr.com/agents/terms","contact":{"url":"https://ordstirr.com"}},"servers":[{"url":"https://rules.ordstirr.com"}],"paths":{"/health":{"get":{"operationId":"health","summary":"Free health check","security":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/babcock/score":{"post":{"operationId":"scoreBabcockMahjongg","summary":"Score a mahjong hand under Babcock's 1923 Rules for Mah-Jongg (public domain), with a page citation for every line","description":"Send the concealed tiles and the sets on the table. For a MAH-JONGG hand (14 tiles, kongs counted as 3) it finds the best legal grouping and scores it by the 1923 Standard Score Sheet: combinations, special bonuses, doublings and the limit. For a hand that did not go out (13 tiles) it re-groups the concealed tiles for the best score, as the book allows, and lists the waits. Every line cites the page of the 1923 book. Unpaid calls receive HTTP 402 with x402 payment terms. Invalid input is rejected with HTTP 400 and never charged.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.02"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"tiles":{"description":"Concealed tiles (include the winning tile, even if it was claimed). String \"123c 55d EEE Rd Rd\" or array of codes. 1c-9c characters, 1b-9b bamboo, 1d-9d dots, E S W N winds, Rd Gd Wd dragons (Wd = the blank White Dragon).","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"table":{"type":"array","maxItems":4,"description":"Sets already on the table before the hand ended.","items":{"type":"object","properties":{"type":{"enum":["chow","pung","kong"]},"tile":{"type":"string","description":"chow: its lowest tile"},"face_down":{"type":"boolean","description":"kong only: declared from the wall with one tile face down, scores as concealed (p. 18)"}},"required":["type","tile"],"additionalProperties":false}},"seat_wind":{"enum":["E","S","W","N"],"description":"The player's own wind. Default E."},"mahjong":{"type":"boolean","description":"true = this hand went MAH-JONGG (won). Default false."},"winning_tile":{"type":"string","description":"Winner only: the tile that completed the hand (must be in tiles)."},"win_by":{"enum":["drawn","discard","loose_tile","stolen_fourth"],"description":"Winner only: drawn from the wall, claimed discard, loose tile after a kong, or stealing the fourth."},"last_tile":{"type":"boolean","description":"Winner only: won on the last tile drawn from the live wall (win_by must be drawn)."},"special":{"enum":["heaven","earth","lucky_thirteen"],"description":"Winner only: Hand From Heaven (East, original 14), Hand From Earth (non-East, East's first discard), Lucky Thirteen."},"limit":{"type":"integer","minimum":0,"maximum":1000000,"description":"Score limit, default 300 (p. 29). 0 = no limit."}},"required":["tiles"],"additionalProperties":false},"example":{"tiles":"Gd Gd Gd Wd Wd EEE 234c","table":[{"type":"kong","tile":"8d"}],"seat_wind":"E","mahjong":true,"winning_tile":"Gd","win_by":"discard"}}}},"responses":{"200":{"description":"Result","content":{"application/json":{"schema":{"type":"object"},"example":{"system":"babcock-1923","mahjong":true,"points_before_doubling":42,"doubling_factor":4,"score":168,"lines":[{"what":"Game (MAH-JONGG)","points":20,"cite":"Standard Score Sheet, Special Bonus Scores: Game or MAH-JONGG, p. 35"}],"terms_url":"https://ordstirr.com/agents/terms","notice":"Informational only. Review before relying on it."}}}},"400":{"description":"Invalid input (never charged)"},"402":{"description":"Payment required (x402). See the PAYMENT-REQUIRED header."},"413":{"description":"Request body too large (never charged)"}}}},"/v1/babcock/settle":{"post":{"operationId":"settleBabcockHand","summary":"Settle one hand of Babcock 1923 Mah-Jongg: who pays whom, with East paying and receiving double","description":"Send the four players' scores (already limited) and the winner's seat (null for a Draw Game). Returns every payment and each seat's net, following Ch. II pp. 26-28. Unpaid calls receive HTTP 402 with x402 payment terms. Invalid input is rejected with HTTP 400 and never charged.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.01"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"scores":{"type":"object","properties":{"E":{"type":"integer","minimum":0},"S":{"type":"integer","minimum":0},"W":{"type":"integer","minimum":0},"N":{"type":"integer","minimum":0}},"required":["E","S","W","N"],"additionalProperties":false},"winner":{"description":"Seat that went MAH-JONGG, or null for a Draw Game.","oneOf":[{"enum":["E","S","W","N"]},{"type":"null"}]}},"required":["scores","winner"],"additionalProperties":false},"example":{"scores":{"E":48,"S":16,"W":4,"N":0},"winner":"E"}}}},"responses":{"200":{"description":"Result","content":{"application/json":{"schema":{"type":"object"},"example":{"winner":"E","net":{"E":288,"S":-68,"W":-104,"N":-116},"terms_url":"https://ordstirr.com/agents/terms","notice":"Informational only. Review before relying on it."}}}},"400":{"description":"Invalid input (never charged)"},"402":{"description":"Payment required (x402). See the PAYMENT-REQUIRED header."},"413":{"description":"Request body too large (never charged)"}}}},"/v1/tafl/moves":{"post":{"operationId":"taflLegalMoves","summary":"List every legal move in a Tablut position (Linnaeus 1732, public domain), with the king's open roads (raichi/tuichu)","description":"Send a 9x9 Tablut position and the side to move; optionally one square to list only that piece's moves. Returns the legal moves in a1-i9 notation, counts, and the king's status. Unpaid calls receive HTTP 402 with x402 payment terms. Invalid input is rejected with HTTP 400 and never charged.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.02"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"rules":{"enum":["linnaeus_1811","linnaeus_latin"],"description":"Default linnaeus_1811."},"board":{"description":"\"start\", or 9 rows of 9 (top row = rank 9): M Muscovite, S Swede, K king, \".\" empty. Array of strings or one string with \"/\" between rows.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"},"minItems":9,"maxItems":9}]},"to_move":{"enum":["muscovites","swedes","attackers","defenders"]},"from":{"type":"string","description":"Only moves of the piece on this square, e.g. \"d9\"."}},"required":["board","to_move"],"additionalProperties":false},"example":{"rules":"linnaeus_1811","board":"start","to_move":"muscovites","from":"d9"}}}},"responses":{"200":{"description":"Result","content":{"application/json":{"schema":{"type":"object"},"example":{"rules":"linnaeus_1811","to_move":"muscovites","count":6,"moves":["d9-d8","d9-d7","d9-d6","d9-c9","d9-b9","d9-a9"],"terms_url":"https://ordstirr.com/agents/terms","notice":"Informational only. Review before relying on it."}}}},"400":{"description":"Invalid input (never charged)"},"402":{"description":"Payment required (x402). See the PAYMENT-REQUIRED header."},"413":{"description":"Request body too large (never charged)"}}}},"/v1/tafl/check-move":{"post":{"operationId":"taflCheckMove","summary":"Referee one Tablut move (Linnaeus 1732, public domain): legal or not and why, captures, king escaped or taken, the board after","description":"Send a 9x9 Tablut position, the side to move and a move like \"e3-c3\". Returns whether it is legal (with the reason if not), the pieces captured, whether the game is over, the king's open roads (raichi/tuichu) and the board after the move, with the law cited. Unpaid calls receive HTTP 402 with x402 payment terms. Invalid input is rejected with HTTP 400 and never charged.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.02"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"rules":{"enum":["linnaeus_1811","linnaeus_latin"],"description":"Default linnaeus_1811."},"board":{"description":"\"start\", or 9 rows of 9 (top row = rank 9): M Muscovite, S Swede, K king, \".\" empty. Array of strings or one string with \"/\" between rows.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"},"minItems":9,"maxItems":9}]},"to_move":{"enum":["muscovites","swedes","attackers","defenders"]},"move":{"type":"string","description":"From-to, e.g. \"d9-d6\" (also \"d9d6\" or \"d9 d6\")."}},"required":["board","to_move","move"],"additionalProperties":false},"example":{"rules":"linnaeus_1811","board":"start","to_move":"muscovites","move":"d9-d6"}}}},"responses":{"200":{"description":"Result","content":{"application/json":{"schema":{"type":"object"},"example":{"legal":true,"captured":[],"game_over":false,"next_to_move":"swedes","terms_url":"https://ordstirr.com/agents/terms","notice":"Informational only. Review before relying on it."}}}},"400":{"description":"Invalid input (never charged)"},"402":{"description":"Payment required (x402). See the PAYMENT-REQUIRED header."},"413":{"description":"Request body too large (never charged)"}}}}}}