Reference
Cuboid engine
import { … } from "@johnmorrisdotca/kyuubu/cuboid";
9.4 kB minified and gzipped, with everything it imports (measured with esbuild)
Exports
| Name | Kind | What it is |
|---|---|---|
CUBOID_MAX_SIDE | constant | The most a side of a cuboid can be. |
CUBOID_MIN_SIDE | constant | The least a side of a cuboid can be. |
CUBOID_PRESETS | constant | The named cuboids, smallest first. |
CUBOID_RANDOM_STATE_MAX | constant | The most states a cuboid has and still has its scramble drawn uniformly out of all of them. |
CUBOID_WORDS | constant | The cuboid's words in both languages. |
CuboidDims | type | The width, height and depth of a cuboid, in cubies: each a whole number from 1 to 7. |
cuboidDragAngle | function | The angle, in degrees, a picked layer has been dragged to: forwards is positive, and it stops at a half turn either way. |
CuboidDragPick | type | The layer a drag has picked: its axis and layer, the way across the screen (a unit vector, x right and y down) that turns it forwards by the right-hand rule, and whether it can only be turned by a half turn. |
CuboidFace | type | One face of a cuboid: how many columns and rows of stickers it has as it is seen from outside, and where its stickers begin in the state. |
cuboidFaceMove | function | A face turned, depth layers in from it (1 is the face itself), on this cuboid: the move, or why not. |
cuboidFaces | function | The six faces of a cuboid, in the order the state is written, with their size and where each begins. |
CuboidFault | type | Why a piece of notation is not a move on this cuboid. |
CuboidKeyReading | type | What a key means on a cuboid: a turn, a depth for the next face letter, or nothing. |
cuboidLayerOf | function | The layer, 0 to the axis's depth − 1 from its negative side, that a cubie centre sits in. |
CuboidLineReading | type | What reading a line gives: its moves, or the first piece that is not one, where it began (counted in characters from 0) and why. |
cuboidMiddleMove | function | The middle layer of an odd side, turned as M, E or S: the move, or why not. |
CuboidMove | type | One turn of a layer: its axis, its layer from the axis's negative side (0 to the axis's depth − 1), and one, two or three quarter turns by the right-hand rule. |
cuboidMoveForRelease | function | The move a release makes: the picked layer turned by those quarters, or null for none. |
cuboidMoveLegal | function | Whether a move can be made on this cuboid: its layer exists, is not the whole puzzle, and its turn is one that layer may make. |
cuboidMoveName | function | What a move of a cuboid turns, in a few plain words, in English or Japanese: R2 is "Right face, twice", 2U2 "Up layer 2, twice", M2 "Middle slice, twice". |
cuboidMoveNotation | function | A move as a person writes it on this cuboid: R, R', R2, 2U2, M2. |
cuboidMovesNotation | function | Moves as a person writes them, a space between each. |
cuboidName | function | A cuboid's name as it is written: 2×3×3. |
cuboidPastCommit | function | Whether a held layer is past its point of no return: letting go now, at rest, makes a move. |
cuboidPermutationOf | function | Where every sticker goes under a legal turn: to[i] is the slot the sticker in slot i lands on. |
cuboidPreset | function | The named cuboid with this key, or undefined. |
CuboidPreset | type | THE NAMED CUBOIDS: the shapes people know, each with a name, the way it is best seen, and a line on what makes it different. |
cuboidQuartersForRelease | function | What letting go makes of a dragged layer, as quarter turns from −2 to 2, where 0 is back where it was. |
CuboidReading | type | What reading one piece of notation gives: the move, or why it is not one. |
CuboidReplayFault | type | Why a cuboid replay could not be planned: which text would not read, where and why. |
CuboidReplayPlan | type | A cuboid solve ready to be played: a ReplayPlan whose size is the longest side, with the puzzle's own dims. |
CuboidReplaySource | type | What a cuboid replay is made from. |
cuboidScrambleLength | function | How many turns a random walk that scrambles a cuboid has: 8, and 2.2 for every layer that is not the whole puzzle, up to 100. |
cuboidSlots | function | Every sticker slot of a cuboid, in the order its state is written, and the way back from a slot to its place. |
cuboidSolved | function | SOLVED: every face one colour, whichever colour it is, so a cuboid solved and then turned whole in the hand is still solved. |
cuboidStickerCount | function | How many stickers a cuboid has: the area of its surface. |
CuboidWords | type | THE CUBOID'S OWN WORDS, in English and Japanese: what a screen reader calls it and what is said when a move cannot be made. |
faultSays | function | The line that says why a piece of notation is not a move on a cuboid. |
HALF_TURN_COMMIT | constant | The point of no return of a half turn, in degrees: the middle of the way round. |
halfTurnOnly | function | Whether a layer turns only by a half turn: it has a slice that is not square. |
hasRandomStateScramble | function | Whether a cuboid has few enough states to be scrambled to one drawn uniformly out of all of them. |
isCuboidDims | function | Whether this is a cuboid the package makes: three whole numbers from 1 to 7, and not 1×1×1, which has nothing to turn. |
isCuboidState | function | Whether a string is a state of a cuboid this size: the right length, and each face's letter as many times as the face has stickers. |
legalCuboidMoves | function | Every move a cuboid can make, by axis, layer and turn. |
legalTurns | function | The turns a layer can make: [1, 2, 3] where its slice is square, [2] where it is not, and none where there is no such layer or the layer is the whole puzzle. |
parseCuboidDims | function | A cuboid read from 2x3x3, 2×3×3, 2 3 3 or 2,3,3: its dims, or null where it is not one the package makes. |
parseCuboidMove | function | One piece of notation as a move, or null where it is not one on this cuboid. |
parseCuboidMoves | function | A line of notation as moves, or null where any of it is not a move on this cuboid. |
pickCuboidDrag | function | The layer a drag across a sticker means, once it can be told: null while the pointer has not gone far enough, while the two layers that carry the sticker are too nearly as likely as each other, or where neither can turn. |
planCuboidReplay | function | A scramble and a solve read, checked and timed. |
randomCuboidScramble | function | A scramble. |
readCuboidKey | function | What a key means on a cuboid, given the depth a digit before it set (1 where none did): the cube's keys (readKey) without the turns of the whole cube. |
readCuboidMove | function | One piece of notation read for this cuboid: R, R', R2, 2R', M2. |
readCuboidMoves | function | A line of notation read for this cuboid, saying which piece is wrong and why where one is. |
sameCuboid | function | Whether two cuboids are the same puzzle turned about in the hand: the same three sides in any order. |
sliceOf | function | The two axes a layer across axis is a slice of, and so what its slice measures: the other two sides. |
solvedCuboid | function | A solved cuboid: each face one letter. |
turnAllCuboid | function | The state after every turn in order. |
turnCuboid | function | The state after one turn; an illegal turn throws a RangeError. |
undoCuboidMove | function | The turn that takes one back. |
undoCuboidMoves | function | A list of moves undone, last first. |