Skip to content

M22: CFOP solver — optimal cross, F2L, full OLL/PLL with named cases#23

Merged
cypherair merged 1 commit into
mainfrom
m22-cfop
Jun 12, 2026
Merged

M22: CFOP solver — optimal cross, F2L, full OLL/PLL with named cases#23
cypherair merged 1 commit into
mainfrom
m22-cfop

Conversation

@cypherair

Copy link
Copy Markdown
Owner

What

Adds CFOP as a fifth solving method: the speedcubing method, with staged playback showing Cross, the four F2L pairs, and the recognized last-layer cases by name ("OLL 27 (Sune)", "PLL · Gc"). Measured average solution: 60.6 moves over 40 seeded random states.

Design

Cross — table-optimal. An exact BFS distance table over the four cross edges (P(12,4) · 2⁴ = 190,080 entries, built once per process in milliseconds) drives a greedy descent. The cross is never longer than 8 moves, and the test suite asserts it.

F2L — macro search instead of a transcribed case table. The plan called for the standard 41-case algorithm table; the implementation instead runs a per-pair Dijkstra over the tracked corner+edge state (24 × 24 codes) with an alphabet of the standard triggers — U turns, the slot's six inserts (R U R' and F' U F families, y-conjugated per slot), and pop-out triggers for the other unsolved slots. Every macro provably preserves the cross and all solved pairs, so any path is clean by construction: no transcription risk, automatic extraction of buried pieces, complete coverage without enumerating cases — and the output still reads like textbook F2L because the macros are the textbook triggers. Pairs are inserted in greedy cheapest-first order.

OLL/PLL — the full 57 + 21 algorithm sets, with nothing resting on transcription.

  • Algorithms are written in extended notation exactly as the standard sheets print them. A new ExtendedNotation parser expands wide turns, M/E/S slices, and x/y/z rotations to outer moves using the same fixed-center equivalences as the scene (M ≙ L′ R + x′ …), tracking the cumulative frame so letters after a rotation land on the right faces. The net frame must end as identity or a pure y rotation (anything else would tilt the U axis and change the algorithm's meaning). Anchor test: M2 U M2 U2 M2 U M2 must equal the H-perm.
  • Recognition keys are derived from the algorithms themselves: the case an algorithm solves is the state its inverse produces from solved. validationIssues() re-checks every entry — parseability, first-two-layer preservation, case uniqueness modulo U rotation — and proves exhaustive coverage of all 216 legal last-layer orientation patterns and all 288 permutation states. The test suite requires the issue list to be empty, so a single mistyped algorithm fails CI with a message naming the entry.
  • OLL recognizes by orientation-pattern lookup under the four U rotations; PLL recognizes by trial (pre-AUF × algorithm × post-AUF), which also absorbs any AUF convention differences between sheets.

Shared refactor: [Move].rotatedY / merged() and the per-move piece-action code tables moved out of BeginnerSolver into shared internal helpers (MoveTransforms.swift); BeginnerSolver delegates, its tests unchanged. The CubeState.rotatedY conjugation the plan sketched turned out to be unnecessary — slot conjugation happens at the move level only.

Verification

  • swift test -c release: 85 tests pass (9 new). The new suite includes: parser anchors; the full table-validation pass (all 119 algorithms checked, both coverage proofs); by-construction tests for every OLL and PLL entry (build the case from the algorithm's inverse plus a random AUF, solve, assert the recognized case name matches); a 200-state sweep with cumulative per-stage invariants (cross → pairs → oriented → solved) and cross-length ≤ 8; average length ≤ 70 (measured 60.6).
  • macOS + iOS Simulator builds green.
  • Interactive (macOS app): Settings › Solving shows 5 methods; scramble → CFOP solve produced a 57-move, 7-stage solution; chips advanced through "Cross", four "F2L pair n" stages, OLL, and "PLL · Gc" to "Solved!".

🤖 Generated with Claude Code

… cases

- ExtendedNotation: expands wide turns, M/E/S slices, and x/y/z
  rotations to outer moves with frame tracking, so the standard OLL
  and PLL algorithm sheets transcribe verbatim; net frame must be
  identity or a pure y rotation; H-perm slice expansion is an anchor
- CFOPAlgorithms: the full 57-case OLL + 21-case PLL sets; recognition
  keys are derived from each algorithm (its inverse builds the case),
  and validationIssues() checks parse, F2L preservation, uniqueness,
  and exhaustive coverage of all 216 orientation + 288 permutation
  last-layer states — the test suite requires the list to be empty
- CFOPSolver: cross via a 190,080-entry exact distance table (always
  ≤ 8 moves); F2L pairs via Dijkstra over the tracked corner+edge
  space with an alphabet of standard triggers (each provably clean,
  so no 41-case table to transcribe), inserted in greedy cheapest-
  first order; OLL by pattern lookup under U rotations; PLL by trial
  with AUF on both sides; ~60-move average solutions
- Shared [Move].rotatedY/merged and PieceAction code tables lifted
  from BeginnerSolver, which now delegates
- App: CFOP method row; staged playback carries case names
  ("OLL 27 (Sune)", "PLL · Gc")

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cypherair cypherair merged commit 1bc467f into main Jun 12, 2026
2 checks passed
@cypherair cypherair deleted the m22-cfop branch June 12, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant