=============================================================================
THE KING'S RULE  -  Apple IIc terminal puzzle  -  v3.1.1 "Fair Cyphers"
=============================================================================

START HERE. Two things, in this order.


1. TO SUBMIT TO FLASHPOINT, UPLOAD THESE TWO FILES  (they are in this folder)
------------------------------------------------------------------------------
    UPLOAD-FIRST--The_Kings_Rule_Flash.zip     <- the Flash (SWF) curation
    UPLOAD-SECOND--The_Kings_Rule_HTML5.zip    <- the HTML5 curation (optional)

They are already in the exact shape the archive wants: one folder, with
meta.yaml + logo.png + ss.png + content/ inside it. Nothing needs repacking.

Upload at  https://fpfss.unstable.life/web    (see flashpoint/README-FLASHPOINT.txt)

Do NOT upload this bundle. It is a delivery folder, not a curation. If a
validator ever says

    "Logo, screenshot, content folder and meta not found.
     Is your curation structured properly?"

that message means exactly one thing: the archive it was handed has no
<meta>/<logo>/<screenshot>/<content> at its top level - i.e. it was handed the
bundle (or a folder wrapped twice), not one of the two UPLOAD- files above.
Both UPLOAD- files were checked against Flashpoint's own Curation-Validation-Bot:
0 errors, 0 warnings, on both.


2. TO PLAY, USE THE  game/  FOLDER
------------------------------------------------------------------------------
    game/game.html        HTML5 build, fully offline. Double-click it.
                          Keep the assets/ folder next to it.
    game/kings_rule.html  The SWF in one page. Needs internet once (Ruffle CDN).
    game/kings_rule.swf   The raw Flash movie. Do not double-click this on a PC
                          that has an audio player mapped to .swf - open it with
                          game/kings_rule.html, or with Ruffle / Flash Player 32.
    game/README.md        The long version: rules, screen flow, fidelity notes.
    game/HOW-TO-OPEN.txt  Plain-language opening instructions.
    game/meta.yaml        Package metadata (version, hashes, build commands).
    game/game.yaml        Game content metadata (chambers, rules, difficulty).


HOW IT PLAYS
------------------------------------------------------------------------------
Nine chambers: eight wardens, then the King. Each warden hides a rule and hands
you three cypher keys. Work out the fourth key.

  * 0-9 type the key (up to four digits), Enter submits, Backspace deletes.
  * ? asks the warden for a hint: the rule plus the working on your own three
    keys. It is free, it never costs a strike, and ? again hides it. That is the
    fairness valve - no chamber is ever unwinnable.
  * A wrong key costs a strike, and THE THREE KEYS DO NOT CHANGE: you get all
    three tries on the same numbers, so the arithmetic is always finishable.
  * Three strikes and that warden casts you out, in its own words.
  * Chamber 9 is the King. He denies every guess. There is no victory screen.


WHAT THIS VERSION FIXES  (3.1.1)
------------------------------------------------------------------------------
Fairness and maths:
  * The DIVIDE room was unwinnable in every single roll: it dealt keys
    [4b, 3b, 2b] but told you to "divide by b", so following the rule gave 2
    instead of b. That pattern is gone; every room's rule is now literal -
    applying it to the third key always produces the accepted answer.
  * Answers were silently clamped to 9999, which could leave the working on
    screen disagreeing with the number the game accepted. Nothing is clamped
    any more; every key and answer is generated inside 1..9999.
  * Rules used to be drawn at random from a growing pool, so chamber 8 could be
    a trivial add while chamber 2 was a multiply. There is now one fixed rule
    family per chamber.
  * A wrong guess used to re-roll the cypher. Now the keys stand: three strikes,
    three tries, same numbers.

Difficulty - exponential, chamber 1 -> 9:
  * Chamber n starts at 100 x 1.9^(n-1), so each chamber is about twice the
    arithmetic of the one before, and the last one sits at the top of the
    4-digit scale:

        1 add             100-250     5 squares (next/2nd/3rd)   1296-3249
        2 subtract        190-475     6 fibonacci                2476-6190
        3 multiply 2 or 3 368-896     7 consecutive primes       4721-9929
        4 halve           685-1249    8 double-then-subtract     8938-9999
                                      9 THE KING                 every guess denied

Variety - so the same question does not come back:
  * The seed is a 32-bit xorshift32 stream (2^31 starting points) instead of a
    16-bit generator that used to collide.
  * Where one rule would only ever produce a handful of rooms, the chamber has
    rule variants: chamber 3 multiplies by 2 or by 3; chamber 5 uses the next
    square, every 2nd square, or every 3rd square.
  * Distinct rooms, counted by dealing each chamber 30,000 times:
        1: 1,963   2: 4,569   3: 87    4: 565
        5: 66      6: 29,576  7: 589   8: 3,319     (about 30,000 in total)
  * The last 400 rooms dealt are remembered and up to 64 candidates are drawn to
    dodge a repeat, so even the 66-room chamber 5 does not normally repeat until
    you have seen them all. The HTML5 build keeps that memory in localStorage
    (it survives a reload); window.kingsRuleResetMemory() clears it.

Bugs found and fixed on the way:
  * HTML5 build: the canvas was CSS-downscaled with nearest-neighbour pixels,
    which dropped glyph rows - "ENTER THE 4th KEY" rendered as "FNTER THF 4th
    KFY". The terminal now draws at 2x and scales smoothly.
  * HTML5 build: the per-warden strike and failure messages were painted and then
    erased by the next frame, so they were effectively invisible. They are now
    proper screen state.
  * The King's three keys were literally 0 / 0 / 0. They are real keys now; he
    still denies every guess.

How it was checked:
  * 72,000 generated rooms (32,000 through the SWF engine, 40,000 through the
    HTML5 engine): 0 invalid, 0 where the rule disagrees with the answer.
  * Each chamber dealt 30,000 times to count its pool, and 300 consecutive deals
    per chamber with the memory on: no repeats.
  * A scripted playthrough walks chambers 1 -> 9 in both builds, solves each one
    from its own hidden rule, and confirms the King denies everything, then
    CAST OUT -> GAME OVER -> CREDITS -> INTRO.
  * Screenshots of every chamber are in screenshots/.


FOLDER MAP
------------------------------------------------------------------------------
    START-HERE.txt                              this file
    UPLOAD-FIRST--The_Kings_Rule_Flash.zip      Flashpoint submission #1
    UPLOAD-SECOND--The_Kings_Rule_HTML5.zip     Flashpoint submission #2
    game/                                       the playable package + metadata
    flashpoint/                                 curation kit: logo, screenshots,
                                                both curation folders, submission
                                                checklist (README-FLASHPOINT.txt)
    screenshots/swf/                            Flash build, 1024x768
    screenshots/html/                           HTML5 build, 1024x768
    CHECKSUMS.md5                               md5 of every file in this bundle
                                                (verify: md5sum -c CHECKSUMS.md5)


LICENCE / ATTRIBUTION
------------------------------------------------------------------------------
Original concept: The King's Rule, Sunburst Communications (1983).
This remake: code, art, audio and font are original work by River Lyle R.
and Arena.ai Agent Mode. Nothing was extracted from the 1983 disk.
=============================================================================
