5×5 scramble: random-move vs random-state
Two methods both "scramble" a 5×5 cube, but they're mathematically very different. Random-move (the WCA standard) walks 60 random steps from solved. Random-state samples **uniformly** from the 2.27 × 10⁷⁴ legal 5×5 states and inverts a solver path back to scramble. The former is browser-instant; the latter is solver-heavy (~1-3 s) but distributes perfectly.
By the numbers
The two methods, step by step
Random-Move
WCAWCA competition standard. Walk 60 random steps from solved; the process is the output.
Pros
- Instant (<1 ms), runs locally in browser
- Zero network — works offline
- Matches WCA Regulation §4d — competition-legal
- Generator is ~50 LoC — auditable
Cons
- A process, not an outcome — short-solve states are systematically over-represented
- Effective state coverage is far smaller than 10⁷⁴
- Two scrambles can collide on the same state (low odds, but the distribution is biased)
Random-State
cube555cs0x7f's 5-phase reduction solver. Sample a state, then invert a solver path.
Pros
- Uniform over the state space — truly random
- Each scramble is independent; no short-solve bias
- Round-trip self-verify: every scramble is checked via CubieCube replay before return
- A real 5×5 random-state solver is rare — cs0x7f/cube555 is the only public implementation
Cons
- Slow: ~1.5 s / scramble on the server (varies by seed)
- Requires network — falls back to random-move if backend is down
- Not WCA-compliant: ~70-move output, not allowed in competition
- Pins 230 MB of pruning tables in memory; JVM total RSS ~540 MB
Inside cube555: anatomy of the 5 phases
cs0x7f's cube555 cuts the 5×5 solve into 5 reduction phases. Each phase has a target sub-state and uses IDA* (iterative deepening A*) plus a pre-computed BFS pruning table (`heuristic`) so each phase terminates within near-optimal depth. The table below lists each phase's coord (the pruning-table index) and table size:
Cold-build of all 13 pruning tables takes ~5 min (BFS, persisted as `.jpdata` / `.jhdata` via Java Serialization); subsequent boots reload from disk in ~3 s. Tables live on the server container.
How it runs on cuberoot.me
Upstream cube555 ships as a Java GUI demo. We adapt it as a long-lived stdio daemon spawned by Hono (TypeScript), talking line-based stdin/stdout protocol. The user click → scramble path goes through:
Real-world bench of the "switch to random-state + click Generate(5/event)" cold path: 17.6 s → 9.69 s (-45%), first-scramble 4.7 s → 2.48 s (-47%). Full numbers in BENCHMARKS.md.
At a glance
| Dimension | Random-Move | Random-State |
|---|---|---|
| WCA-compliant | ✓ | ✗ |
| Length | 60 | ~70 |
| Generation time | <1 ms | ~1.5 s |
| Where it runs | browser (local) | server (daemon) |
| State distribution | non-uniform, biased to easy solves | uniform |
| Needs pruning tables? | none | ~230 MB |
| Needs network? | no | yes (fallback to random-move on failure) |
| Implementation complexity | ~50 lines of TypeScript | ~20 Java classes, ~5000 LoC |
| Use when | competition, official timing, offline practice | home training, dataset sampling, unbiased benchmarks |
References
- cs0x7f/cube555 — upstream 5-phase reduction solver (Java); our daemon wraps it
- cs0x7f/min2phase — cube555's Phase 5 driver — Kociemba two-phase for the residual 3×3
- WCA Regulation §4: Scrambling — why competitions use 60-move random-move (§4d4)
- cubing.js — Lucas Garron's in-browser random-move / random-state generators (random-state for 2×2-4×4, random-move for 5×5+)
- Herbert Kociemba — Cube Explorer — Original paper + implementation of the two-phase algorithm — the de-facto 3×3 solver standard
- IDA* algorithm (Wikipedia) — Korf 1985 — the search kernel cube555 uses at every phase
- BENCHMARKS.md — real-world numbers for our daemon (JVM → batch SSE → GraalVM native → client cold-path fix)