Reference · Cube engine and views
randomScramblefunction
A scramble of length turns, each of one layer chosen at random, never two
in a row about the same axis, so no turn undoes or joins the one before it
and the count is the count. Never leaves the cube solved: a turn is added
until it is not.
random is a number in [0, 1), like Math.random; pass a seeded one
(seededRandom) to get the same scramble from the same seed everywhere.
With faces, only the six outer faces are turned.
Import it
import { randomScramble } from "@johnmorrisdotca/kyuubu";
Definition
function randomScramble(n: number, length: number, random?: () => number, options?: ScrambleOptions): CubeMove[]
Parameters
| Name | Type | Description |
|---|---|---|
n | number | The cube’s side length. |
length | number | The requested number of scramble moves; omitted cuboid lengths use its scrambling strategy. |
random (optional) | () => number | A source of numbers in [0, 1), such as seededRandom(seed). |
options (optional) | ScrambleOptions | Options for this call; omitted fields retain their documented defaults. |
Returns
CubeMove[]
A scramble of length turns, each of one layer chosen at random, never two in a row about the same axis, so no turn undoes or joins the one before it and the count is the count. Never leaves the cube solved: a turn is added until it is not. random is a number in [0, 1), like Math.random; pass a seeded one (seededRandom) to get the same scramble from the same seed everywhere. With faces, only the six outer faces are turned.
Examples
import { movesNotation, randomScramble, seededRandom } from "@johnmorrisdotca/kyuubu";
console.log(movesNotation(randomScramble(3, 8, seededRandom("docs")), 3));U F2 L D2 F E B' L'What it prints (run when this page was built)