flix

0.75.3

Orbit64.Coord

enum Coord with Eq, ToStringSource
case CornerCoord(Vector[Int32], Vector[Int32])case MidgeCoord(Vector[Int32], Vector[Int32])case WingCoord(Vector[Int32])case CenterCoord(Vector[Int32])

The state of a single orbit.

Permutations are given slot-wise: entry i names the piece sitting in slot i, with the solved cube being the identity. Orientations are given in the same slot order, and the redundant final entry is carried here even though rank drops it -- it is cheap to keep, and it lets faultOf check the constraint the format relies on.

Instances

instance Eq[Coord]Source
instance ToString[Coord]Source

Definitions

def faultOf(c: Coord): Option[String]§ Source

Why c is not a state a cube can be in, or nothing when it is one.

The constraints are stated once, here, and used twice: as the predicate isValid, and as the reason Orbit64.State.encode gives when it refuses. A caller building coordinates from its own model gets told which rule it broke rather than that something, somewhere, was wrong.

Every check is total on any vector it is handed, including one of the wrong length -- which matters, because this runs before rank, and rank would read off the end of a short orientation vector.

def isValid(c: Coord): Bool§ Source

Whether c satisfies the constraints every reachable cube obeys.

def kind(c: Coord): Orbit§ Source

The kind of orbit c describes.

def rank(c: Coord): BigInt§ Source

The integer coordinate of c, in [0, Orbit.radix(kind(c))).

Permutation and orientation are combined by mixed radix rather than stored in separate fields, so no bits are lost between them.

def unrank(o: Orbit, v: BigInt): Coord§ Source

The inverse of rank: the state of an orbit of kind o with coordinate v.