UNPKG

arcanumcube

Version:
133 lines (131 loc) 4.6 kB
declare const CUBE_SIZE = 3; declare const SIDE_MAX: number; declare const SIDE_MIN = 0; declare const SIDE_MIDDLE: number; declare const STICKER_COLOR: { UP: number; FRONT: number; RIGHT: number; DOWN: number; BACK: number; LEFT: number; PLAIN: number; }; type StickerColor = (typeof STICKER_COLOR)[keyof typeof STICKER_COLOR]; declare const CUBE: { readonly AXIS: "axis"; readonly CENTER: "center"; readonly EDGE: "edge"; readonly CORNER: "corner"; readonly STICKER: "sticker"; }; type CubeType = (typeof CUBE)[keyof typeof CUBE]; declare const FACE: Record<string, number>; type Face = (typeof FACE)[keyof typeof FACE]; declare const TWIST: { readonly U: "U"; readonly UR: "U'"; readonly F: "F"; readonly FR: "F'"; readonly R: "R"; readonly RR: "R'"; readonly D: "D"; readonly DR: "D'"; readonly B: "B"; readonly BR: "B'"; readonly L: "L"; readonly LR: "L'"; readonly M: "M"; readonly MR: "M'"; readonly E: "E"; readonly ER: "E'"; readonly S: "S"; readonly SR: "S'"; readonly U2: "U2"; readonly F2: "F2"; readonly R2: "R2"; readonly D2: "D2"; readonly B2: "B2"; readonly L2: "L2"; readonly M2: "M2"; readonly E2: "E2"; readonly S2: "S2"; }; type Twist = (typeof TWIST)[keyof typeof TWIST]; declare const SINGLE_TWIST_LIST: readonly ["U", "U'", "F", "F'", "R", "R'", "D", "D'", "B", "B'", "L", "L'", "M", "M'", "E", "E'", "S", "S'"]; declare const DOUBLE_TWIST_LIST: readonly ["U2", "F2", "R2", "D2", "B2", "L2", "M2", "E2", "S2"]; declare const TWIST_LIST: ("U" | "U'" | "F" | "F'" | "R" | "R'" | "D" | "D'" | "B" | "B'" | "L" | "L'" | "M" | "M'" | "E" | "E'" | "S" | "S'" | "U2" | "F2" | "R2" | "D2" | "B2" | "L2" | "M2" | "E2" | "S2")[]; declare const CUBE_ANGLES: Twist[][][][]; declare const TWIST_RULE: Record<Twist, { axis: [x: number, y: number, z: number]; levels: number[]; steps: number; }>; declare function getStickerIndex(x: number, y: number, z: number, face: Face): number; declare function getCubeFromStickerIndex(index: number): [x: number, y: number, z: number, face: Face]; declare function getRandomTwistList(steps?: number): Twist[]; declare function MatchGoalState(state: StickerColor[]): boolean; type Sticker = { face: Face; color: StickerColor; }; /** One small cube class that makes up the Arcanum Cube */ declare class Cube { type: string; position: { x: number; y: number; z: number; }; protected _stickers: Sticker[]; protected _initialPosition: { x: number; y: number; z: number; }; constructor(x: number, y: number, z: number); getStickers(): Sticker[]; init(): void; reset(): void; rotateStickerFace(twists: Twist[], reverse?: boolean, init?: boolean): void; } /** Arcanum Cube object class */ declare class ArcanumCube { /** output debug information to console */ debug: boolean; /** history of twisting */ protected _history: Twist[]; /** cube objects matrix */ protected _matrix: Cube[][][]; constructor(options?: { debug?: boolean; }); init(): void; reset(): void; scramble(steps?: number): void; undo(steps?: number): void; isSolved(): boolean; getHistory(): Twist[]; getUndoList(steps?: number): Twist[]; twist(twist: Twist | Twist[], reverse?: boolean): void; private _twist; rotateMatrix(twist: Twist, reverse?: boolean): void; getStickerColors(): StickerColor[]; dumpStickers(): void; } declare function getNextStickerColors(stickers: StickerColor[], twist: Twist): StickerColor[]; declare function getArrayForTensor(stickers: StickerColor[]): number[][][]; declare function getCubePermutationGroup(twist: Twist, reverse?: boolean): { before: number[][]; after: number[][]; stickers: { before: number[]; after: number[]; }; }; declare function getStickerPermutationGroup(position: [x: number, y: number, z: number], position2: [x: number, y: number, z: number], twists: Twist[], reverse?: boolean): { before: number[]; after: number[]; }; export { ArcanumCube, CUBE, CUBE_ANGLES, CUBE_SIZE, Cube, DOUBLE_TWIST_LIST, FACE, MatchGoalState, SIDE_MAX, SIDE_MIDDLE, SIDE_MIN, SINGLE_TWIST_LIST, STICKER_COLOR, TWIST, TWIST_LIST, TWIST_RULE, getArrayForTensor, getCubeFromStickerIndex, getCubePermutationGroup, getNextStickerColors, getRandomTwistList, getStickerIndex, getStickerPermutationGroup }; export type { CubeType, Face, Sticker, StickerColor, Twist };