Skip to content

WCA Implementation Plan #169

Open
Open

Description

@lgarron

WCA Implementation Plan

The Twizzle Pattern Searcher (twips) has been planned as a replacement for TNoodle for a while. @gregorbg originally posted about this at: #4

twips is now very close to usable, as can be seen by the fact that https://experiments.cubing.net/cubing.js/mark3/ generates printable scramble sheets in a browser almost entirely based on twips. However, for this to get out the door and usable for all competition, it needs more work. The following are the main categories of work:

  • Scramble generation
  • Audit mechanism
  • WCA website
  • scramble-table

Planned flow

The following is a proposed "minimum viable product" (MVP) flow for scrambles:

  1. A Delegate presses a button on the competition page.
    1. This derives a secret "competition seed" for all scrambles of the competition according to this online protocol, using code that uses twips through cubing.js.
      1. The server receives a (hash) commitment to this secret seed that it can publish to an audit log, but does not receive the secret seed value.
      2. This competiton seed is used to generate a seed for each event, which are in turn is used to generate seeds for each round, and in turn for each scramble. Every scramble is uniquely determined by the competition-level secret seed and its place in the competition (event + round + group + attempt, and puzzle number in the case of the multi-blind).
    2. The Delegate can select what scrambles to generate PDFs for. Scrambles are then generated for these events, but other scrambles are not generated at this point.
      1. For laptop-scramble competitions this only needs to include 3×3×3 FMC scrambles, which means this process can be very fast.
      2. If the Delegate wants to generate PDFs for some or all other scrambles, this is still possible now or later any time before or even during the competition (but will of course take a bit of time).
      3. Certain unofficial events (e.g. Kilominx, FTO) can already be included if desired.
    3. The Delegate receives a .zip file that they are told to safeguard. It includes:
      1. SECRET: A file that stores an (obfuscated) copy of the secret competition seed.
      2. SECRET: A copy of the passcodes for each group (same as before).
      3. PDFs that were selected.
      4. A JSON file with metadata similar to the current WCIF file, but with passcode-encrypted seeds down to the group level.
      5. A self-contained HTML file that can be used for offline scramble tables, which includes the JSON data.
  2. Scramble tables will open the self-contained HTML file, which is an app based on scramble-table1. This will be similar to PDF displays (including passcode distribution), except:
    1. Scrambles can be laid out on the screen more easily.
    2. Any number of extras can be calculated on demand.
    3. There are some "nice-to-have" features like being able to click on a move in a scramble to check the partially scrambled state (if you're not sure whether you performed a given move correctly).
    4. This can support high-assurance features based on tracking which scrambles and extras were used, and even which scrambler performed which scramble for which competitor (although this is not necessary for the MVP).
  3. After the competition, the Delegate submits the competition secret seed. The WCA server verifies that it matches the commitment and then publishes it, at which point the public can derive or verify all scrambles.
    1. Scrambles can also be generated and published by the WCA website once it has the competition seed.

In case the Delegate loses the competition seed, we can implement a way allow a Delegate to generate a new secret seed from scratch or even offline (but this should be an auditable exception that will require a good explanation).

Remaining Work

Here is the work that I think is relevant for a full WCA launch:

Testing

Feature Effort Category Notes
Implement the UI for the WCA website (generate seed, select PDFs, generate and download .zip) Moderate WCA website
Automated client-side PDF generation Low to moderate WCA website
Implement the modified WCIF JSON generation Low Scramble generation
Implement a scramble table layout for typical rounds
(e.g. 5 attempts + extras)
Low scramble-table
Switch random-move scrambles to seed-derived Low Scramble generation

Full launch

The main challenge is that 4×4×4 scrambles are unoptimized and therefore prohibitively slow (≈30 seconds per scramble). Other scrambles are "good enough" but could be improved to generate scrambles faster, and/or scrambles that are shorter.

Feature Effort Category Notes
Publish seed commitments at derivation time. Low WCA website
Finalized puzzle definitions Moderate Scramble generation Allows independent compatible verification and implementation.
Platform-independent seed derivation algorithm Low Auditability
Independent derivation verification / QA Moderate Auditability
FTO scramble optimization Moderate Scramble generation Port optimizations (mainly multi-move generators for the search tree) from xyzzy and Chen Shuang.
4×4×4 scramble optimization High Scramble generation Implement important symmetry reduction optimizations from Chen Shuang's code.
3×3×3 scramble optimization Moderate Scramble generation Implement common optimizations like cross-phase pruning, optimized state representations, and symmetry reduction. Current scrambles are "good enough" for laptop scrambles, but generating an entire competition's worth ahead of time could take several minutes.

Eventually

Feature Effort Category Notes
Encrypted seed recovery for the WST Low to moderate Scramble generation Allows a group of WST members to recover a committed competition seed if the Delegate lost it.
Hosted scramble table app with in-band passcode distribution Moderate to high scramble-table
Audit trail of scramble tables Low to moderate scramble-table Keep track of which tables used which scramble groups, including which extras were generated.
Investigate better random-move scrambling algorithms ? Scramble generation xyzzy has done some research into e.g. Megaminx and big cube scramble entropy.

Footnotes

  1. It is also easy to support other mechanisms, such as a website or a more performant local server that can be run using a Tauri app build,npx, or cargo install. This is mostly a matter of UX, auditability, and what mechanisms we want to commit to supporting. ↩

Activity

  1. gregorbg commented on Sep 26, 2026

    @gregorbg

    Yay! Some follow-up questions:

    • Planned flow 1.ii.a: What if a laptop-only competition has no FMC? The Delegate would then not need to pre-generate any scrambles at all. The download is effectively "just" the (obfuscated) seed file. What about baking the idea into the protocol that the seed file always gets downloaded independently?
      • This would mean educating Delegates that "This file is effectively your scrambles".
      • They could then present that seed to any scrambling program at any point. If they download the seed and initially forget to also generate FMC due to human error, they can simply generate them later.
      • The idea here is to educate the Delegates about the importance of the "seed file". Everything else, including pre-generated scrambles for FMC and such, can be done after the fact.
    • Full launch for 444, FTO, 333: How much more details are you able to provide about the specifics here?
      • For example on 444, your table says "Implement [...] from Chen Shuang's code". Have you already taken a look at the code, ie do you already have an understanding of which symmetry reduction optimizations would need to be implemented?
    • Who defines the concrete algorithm of turning a seed into a scramble?
      • From your previous ADR write-up, I understand that one specific scramble relies on one specific sub-seed derived through event ID, sub-event ID, salt and filtering candidate. Say I have all that, and I perfectly follow this guide, and the end result is (for the sake of my example) 0x67090777cf. How do I turn the information 0x67090777cf into the 333 scramble with red, red, yellow, white, green, white, blue, blue, blue on the top face?
      • When your "Planned Flow" point 3 says the WCA server verifies, then a concrete specification of "How to turn one specific seed into a specific random state" is also relevant. Otherwise even when the commitment is correct and the root seed is provided, how or what should we verify?
      • When we don't have random state (think 555+, Mega) then does the random seed get translated into the random moves directly?
  2. lgarron commented on Sep 26, 2026

    @lgarron
    MemberAuthor
    • Planned flow 1.ii.a: What if a laptop-only competition has no FMC? The Delegate would then not need to pre-generate any scrambles at all. The download is effectively "just" the (obfuscated) seed file. What about baking the idea into the protocol that the seed file always gets downloaded independently?

    We could, but I think downloading two things could be confusing? We already have the precedent of a single download containing both secrets and scrambles.

    • This would mean educating Delegates that "This file is effectively your scrambles".

    Yes, this will definitely be an important point!

    • They could then present that seed to any scrambling program at any point. If they download the seed and initially forget to also generate FMC due to human error, they can simply generate them later.
    • The idea here is to educate the Delegates about the importance of the "seed file". Everything else, including pre-generated scrambles for FMC and such, can be done after the fact.

    Yeah, the secrets file can definitely be used like that. But I think leaving out FMC scrambles by default would be a worse UX?
    Even setting aside what Delegates are used to, a "one-stop shop" button is one less item on a competition preparation checklist.

    • Full launch for 444, FTO, 333: How much more details are you able to provide about the specifics here?

      • For example on 444, your table says "Implement [...] from Chen Shuang's code". Have you already taken a look at the code, ie do you already have an understanding of which symmetry reduction optimizations would need to be implemented?

    I think we mainly just need the 3-dimensional cube symmetries, but I don't have all the info paged in. One useful step would be to exactly write down what

    • Who defines the concrete algorithm of turning a seed into a scramble?

      • From your previous ADR write-up, I understand that one specific scramble relies on one specific sub-seed derived through event ID, sub-event ID, salt and filtering candidate. Say I have all that, and I perfectly follow this guide, and the end result is (for the sake of my example) 0x67090777cf. How do I turn the information 0x67090777cf into the 333 scramble with red, red, yellow, white, green, white, blue, blue, blue on the top face?

    This is "Platform-independent seed derivation algorithm" in the tables above. Right now, e.g. twips scramble 333 uses seed derivation by implementing a seed-based RngCore using SHA-256 which is then used by orbit randomization as hardcoded for each monoscramble event. We need to bypass the Rust-specific RngCore implementation to make this platform-independent and I would certainly like a spec that someone can implement without consulting our code at all (which requires "Finalized puzzle definitions" and if someone did this then I think it would be the best way to cover "Independent derivation verification / QA").

    • When your "Planned Flow" point 3 says the WCA server verifies, then a concrete specification of "How to turn one specific seed into a specific random state" is also relevant. Otherwise even when the commitment is correct and the root seed is provided, how or what should we verify?

    If we don't want to enforce an audit trail from the scramble tables (at least initially), there isn't anything to verify but the competition seed. By default, scramble-table only has a way to generate scrambles to the events, rounds, and groups specified on the WCA website ahead of time anyhow (since those are the encrypted seeds in the JSON). So the server can know exactly what groups were possibly used, i.e. which ones would have been generated under TNoodle.

    (We'll have to decide if we want an override to support adding rounds/events without going to the WCA website, but that's not a terribly difficult implementation detail.)

    Scrambles are also currently deterministic because they are generated single-threaded using deterministic canonical sequence iteration order and pruning:

    twips derive \
      67002dfc95e6d4288f418fbaa9150aa65b239fd5581f2d067d0293b9321a8b67 \
      EBNLEND@MABLNHJFHGFEKFIA@DNBKABHHNANA@FD@KKADJAKNFCIJNJGIFCBLEDF/scrambles/333/r1/g1/a1/333/sub1

    And even if we go multi-threaded (which there is basically no need for) there are ways to keep the output scramble deterministic for a given twips version range. In fact, given the number of times the WRC has had to analyze an exact scramble alg this is probably very desirable. So there shouldn't be a need to check actual generated scramble algs (although it also wouldn't hurt, if/when we do implement a scramble table audit trail).

    • When we don't have random state (think 555+, Mega) then does the random seed get translated into the random moves directly?

    Yes, for this we can just use the random number generator to run through canonical sequences like a Markov chain. We can do that by swapping out this call. This is small, but I've added it to the list above.

  3. gregorbg commented on Sep 26, 2026

    @gregorbg

    Cool! The whole thing about file downloads and Delegate ergonomics doesn't really touch the programming much. I think it's stuff that mainly has to be decided outside of code, and then the code can easily and quickly follow suit.

    This is "Platform-independent seed derivation algorithm" in the tables above. Right now, e.g. twips scramble 333 uses seed derivation by implementing a seed-based RngCore using SHA-256 which is then used by orbit randomization as hardcoded for each monoscramble event. We need to bypass the Rust-specific RngCore implementation to make this platform-independent and I would certainly like a spec that someone can implement without consulting our code at all (which requires "Finalized puzzle definitions" and if someone did this then I think it would be the best way to cover "Independent derivation verification / QA").

    Just want to make sure that we're on the same page here. From my understanding, this "protocol" that we need to implement consists of two steps:

    1. Given a seed, turn this seed into randomness (random numbers) in a platform-independent, platform-agnostic way
    2. Given the (platform-independent) randomness, translate that randomness to a specific...
      • 3x3x3 state
      • 5x5x5 move sequence
      • etc...

    Point (1) is cut-and-dry in terms of a specification. Point (2) has the potential for doing a lot of documentation work and coming up with a kind of "WCA scramble state protocol". The implementation that you linked previously is only reproducible (given the same randomness seed) because it uses a fixed (canonical?) order for the orbits.
    If someone were to create a different but mathematically valid definition file for the 3x3, the same random number generator with the same seed would yield a different result (in terms of random puzzle state and resulting scramble move sequence).
    How deep into the weeds of specifying a "canonical puzzle orbit order w.r.t. scrambles" should we go?

    Random thought: If we specify this in great detail, then even TNoodle could be used during a transition phase to generate scrambles given a seed file provided by the Delegate.

  4. lgarron commented on Sep 27, 2026

    @lgarron
    MemberAuthor

    Indeed, you've hit on exactly the parts that next need expanding.

    We first need lone-term stable puzzle definitions, which is the "Finalized puzzle definitions" entry. Right now some of them are guaranteed to be stable (e.g. Reid + Speffz order for cubes) but we need to make sure the others are in a state we're okay to support indefinitely.

    How deep into the weeds of specifying a "canonical puzzle orbit order w.r.t. scrambles" should we go?

    I think I'm just about done designing this part. If you look at the orbit randomization, you'll notice that there are options for constraints. I basically made a bet that the number of options is actually pretty limited and nothing would be prohibitive to encode, and I think this basically worked out. The code can be directly translated into JSON:

    {
      "monoscramble_event_id": "333_no_inspection",
      "orbit_randomization": [
        {
          "orbit_name": "CENTERS",
          "constraints": {
            "cartesian_generators": [
              ["", "x", "x2", "x'", "z", "z'"],
              ["", "y", "y2", "y'"]
            ]
          }
        },
        {
          "orbit_name": "EDGES",
          "constraints": { "orientation": "sum-to-zero" }
        },
        {
          "orbit_name": "CORNERS",
          "constraints": {
            "permutation": { "even_with": ["CENTERS", "EDGES"] },
            "orientation": "sum-to-zero"
          }
        }
      ]
    }
    {
      "monoscramble_event_id": "fto",
      "orbit_randomization": [
        { "orbit_name": "CORNERS" },
        {
          "orbit_name": "CENTERS",
          "constraints": { "subset": [0, 1, 2, 3, 4, 14, 15, 16, 19, 20, 22, 23] }
        },
        {
          "orbit_name": "CENTERS",
          "constraints": { "subset": [5, 6, 7, 8, 9, 10, 11, 12, 13, 17, 18, 21] }
        },
        {
          "orbit_name": "EDGES",
          "constraints": { "permutation": "even-parity", "orientation": "all-zero" }
        }
      ]
    }

    I think the main alternatives are:

    • Spec and implement Schreier-Sims in a deterministic way. This isn't extremely hard, but it's not necessarily fast and probably more gnarly than necessary. It also doesn't work for puzzles like Square-1.
    • Encode the output of Schreier-Sims in an SGS. We've actually done this with some puzzles. It… takes up a lot of space.
    • Hardcode imperative instructions like the JSON above, and prove these correct.

    There's definitely a lot of sublety. For example, the FTO definition above is not valid for super FTO and puzzle definitions will have to be specifically selected to allow simple randomization JSON.

    But I think the current orbit randomization code is pretty straightforward to turn into pseudo-code that deterministically uses the RNG for Fisher-Yates. Since this is not really a hot code path, it's certainly easy to choose simplicity and correctness over an extra few percent of speed.

    Random thought: If we specify this in great detail, then even TNoodle could be used during a transition phase to generate scrambles given a seed file provided by the Delegate.

    … probably? But I've never had a good experience trying to write or maintain code that translates between puzzle definitions.

  5. jfly commented on Oct 10, 2026

    @jfly
    Member

    I have read through the above and the linked Scramble derivation
    ADR
    (although I have only skimmed the ADR, and not taken the time to truly internalize it). Some thoughts:

    I fully agree with the desire to make the seed be enough information to both generate scrambles and verify them. However, even if we fully specify twips's abstract mathematical behavior (which I think would be a mistake), there are other reasons the seed as currently specified isn't enough:

    • The WCA has every right to change its filtering rules in the future. A seed that today generates a 4 move 2x2x2 scramble could in the future generate a 5 move 2x2x2 scramble if the WCA changes the 2x2x2 filter requirement.
    • The WCA may decide to change the way it scrambles a given puzzle (for example, we changed the way megaminx scrambles worked with Pochmann style scrambles, we changed the way clock scrambles were done, maybe 5x5x5 random state becomes feasible someday, etc).
    • All software has bugs. We should fix those bugs as we discover them, but that might break our ability to regenerate old scrambles.

    I think the best approach is to attach a twips version to the seed at some point. That leaves us free to change twips's behavior for the better without stressing out too much about backwards compatibility. It also implicitly captures whatever regulations were in effect at the time.

    Separately, while I do like the direction being proposed here, I think it's too much happening all at once. I said before, and I'll say it again: I would start by swapping out the mathematical guts of TNoodle to use twips and not change anything else. Call it a new version of TNoodle (or call it the version version of twips, whatever) and get delegates pounding on the code. Introduce seeded scrambles sometime after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions