flix

0.75.3

Orbit64.State

A compact, URL-safe interchange format for framed n x n x n cube state.

The whole state is one integer. Each orbit contributes a coordinate in a range of exactly its own size (see Orbit.radix), and odd cubes add one of the 24 fixed-center frames. The values are combined by mixed radix and written in base64url at a fixed width. Nothing is spent on separators or field alignment; the two leading zero bits identify this member of the Orbit64 token family as state.

The encoding is canonical for a given slot convention: two coordinate states produce the same token exactly when they are the same state, so string equality is state equality. The qualifier matters -- a token records ordinals and no geometry, so which physical piece "wing 17" is has to be agreed elsewhere. Orbit64.Net is where this package says what it assumes.

cube bits chars
2x2x2 26.39 5
3x3x3 69.82 12
4x4x4 156.96 27
5x5x5 251.90 43
6x6x6 390.58 66
7x7x7 537.05 90

Widths are distinct and grow as n^2, so a token's length identifies the puzzle it belongs to.

Definitions

def canonical(orbits: List[Coord]): FramedState§ Source

Construct a state in the canonical reference frame.

def carriesFrame(n: Int32): Bool§ Source

Whether n has fixed centers whose physical frame must be carried.

def coordinateCount(n: Int32): BigInt§ Source

The number of legal coordinate states before the optional frame factor.

def decode(n: Int32, token: String): Result[String, FramedState]§ Source

Decode a frame-aware state.

def encode(n: Int32, state: FramedState): Result[String, String]§ Source

Encode a frame-aware state.

On even cubes the frame must be canonical: movable center coordinates already determine the pose, so recording another 24-way choice would duplicate every state. Odd cubes carry one of the 24 fixed-center frames explicitly.

def frame(state: FramedState): Frame§ Source

The reference frame recorded by state.

def orbits(state: FramedState): List[Coord]§ Source

The orbit coordinates recorded by state.

def parityFault(n: Int32, orbits: List[Coord]): Option[String]§ Source

Why an odd cube's corners and midges cannot sit in these permutations, or nothing. The law couples two orbits, so Orbit64.Coord.faultOf cannot state it; encode and Orbit64.Net.fromFacelets share it from here.

def solved(n: Int32): FramedState§ Source

The framed state of a solved n x n x n cube.

Every coordinate is zero, so this always encodes to a run of As.

def stateCount(n: Int32): BigInt§ Source

The number of frame-aware states the state format addresses.

def width(n: Int32): Int32§ Source

The width for stateCount, keeping the leading state class bits.