Reference · Cube engine and views
Guideclass
A guide through a list of moves or the method's steps, for a cube of side
n starting from state.
Import it
import { Guide } from "@johnmorrisdotca/kyuubu";
Definition
class Guide
new Guide(state: string, n: number, source: GuideSource): Guide
Parameters
| Name | Type | Description |
|---|---|---|
state | string | The initial sticker-state string. |
n | number | The cube’s side length. |
source | GuideSource | Explicit guide moves or the solving method. |
Members
| Name | Type | Description |
|---|---|---|
n | number | The cube's side. |
state | string | The cube as the guide has it: where it started, with every turn it has been told of or has handed out. |
next | GuideStep | null | The movement to make now, or null when there is nothing left to make. While there is a detour it is still the movement to come back to. |
detours | readonly CubeMove[] | The turns made that were not asked for, oldest first. |
done | number | How many movements have been finished, over every step of the method. |
finished | boolean | Whether there is nothing left to make. |
heard | (move: CubeMove): GuideHeard | A turn made on the cube, by a person or anything else, told to the guide.
|
takeBack | (): CubeMove[] | The turns that take every detour back, last first, as the guide now has them made: turn them on the cube without telling the guide again. |
makeNext | (): CubeMove[] | Every detour taken back and the movement made, as the guide now has it: the turns to make on the cube, without telling the guide again. |
Examples
import { Guide, parseMove, solvedCube } from "@johnmorrisdotca/kyuubu";
const guide = new Guide(solvedCube(3), 3, { moves: "R U" });
console.log(guide.next?.text);
console.log(guide.heard(parseMove("R", 3)!));R
doneWhat it prints (run when this page was built)