Skip to the content

Kyuubuキューブ

Turn CSS 3D cubes by touch, keys or notation, reproduce a scramble from a seed, and follow a solve one named step at a time.

Kyuubu (キューブ) is the Japanese spelling of cube. About the name

Contents

Reference · Cuboid engine

randomCuboidScramblefunction

A scramble. Without a length, a puzzle that has few enough states (hasRandomStateScramble) is scrambled to a state drawn uniformly from all the states that are not solved, by the shortest turns that reach it; any other is scrambled by a random walk of cuboidScrambleLength turns, one more than that half the time, so that a puzzle whose graph has two sides can land on either. With a length, a random walk of exactly that many turns, each of a layer chosen at random and a turn that layer can make, never two in a row of the same layer, which would join into one. Never leaves the puzzle solved: a turn is added until it is not.

random is a number in [0, 1), like Math.random; pass seededRandom(seed) for the same scramble from the same seed everywhere.

Import it

import { randomCuboidScramble } from "@johnmorrisdotca/kyuubu/cuboid";

Definition

function randomCuboidScramble(dims: CuboidDims, length?: number, random?: () => number): CuboidMove[]

Parameters

NameTypeDescription
dimsCuboidDims

The cuboid’s x, y and z dimensions, in that order.

length (optional)number | undefined

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).

Returns

CuboidMove[]

A scramble. Without a length, a puzzle that has few enough states (hasRandomStateScramble) is scrambled to a state drawn uniformly from all the states that are not solved, by the shortest turns that reach it; any other is scrambled by a random walk of cuboidScrambleLength turns, one more than that half the time, so that a puzzle whose graph has two sides can land on either. With a length, a random walk of exactly that many turns, each of a layer chosen at random and a turn that layer can make, never two in a row of the same layer, which would join into one. Never leaves the puzzle solved: a turn is added until it is not. random is a number in [0, 1), like Math.random; pass seededRandom(seed) for the same scramble from the same seed everywhere.

Examples

import { cuboidMovesNotation, randomCuboidScramble } from "@johnmorrisdotca/kyuubu/cuboid";
import { seededRandom } from "@johnmorrisdotca/kyuubu";

const dims = [2, 3, 3] as const;
console.log(cuboidMovesNotation(randomCuboidScramble(dims, 8, seededRandom("docs")), dims));
R2 B2 F2 R2 F2 D2 L R

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kyuubu 1.14.1.