UNPKG

gan-i3-356-bluetooth

Version:

Library for connecting to and interacting with Bluetooth-enabled Rubik's cubes (GAN)

112 lines 3.86 kB
/** * Converts between Rubik's cube states and unique numbers (0 to 43,252,003,274,489,856,000 - 1) * Uses Lehmer codes for permutations and direct encoding for orientations */ export declare class CubeNumberConverter { private static readonly TOTAL_STATES; private static readonly CORNER_PERMS; private static readonly CORNER_ORIS; private static readonly EDGE_PERMS; private static readonly EDGE_ORIS; /** * Converts corner permutation to Lehmer code * @param corners Array of 8 corner positions (0-7) * @returns Lehmer code for the permutation */ private static cornersToLehmer; /** * Converts Lehmer code to corner permutation * @param lehmer Lehmer code * @returns Array of corner positions */ private static lehmerToCorners; /** * Converts edge permutation to Lehmer code * @param edges Array of 12 edge positions (0-11) * @returns Lehmer code for the permutation */ private static edgesToLehmer; /** * Converts Lehmer code to edge permutation * @param lehmer Lehmer code * @returns Array of edge positions */ private static lehmerToEdges; /** * Extracts corner orientations from corner array * @param ca Corner array from CubieCube * @returns Array of orientations (0-2) */ private static getCornerOrientations; /** * Extracts corner positions from corner array * @param ca Corner array from CubieCube * @returns Array of positions (0-7) */ private static getCornerPositions; /** * Extracts edge orientations from edge array * @param ea Edge array from CubieCube * @returns Array of orientations (0-1) */ private static getEdgeOrientations; /** * Extracts edge positions from edge array * @param ea Edge array from CubieCube * @returns Array of positions (0-11) */ private static getEdgePositions; /** * Converts corner orientations to a number (base 3) * @param orientations Array of 7 orientations (8th is determined by others) * @returns Number representing orientations */ private static cornerOriToNumber; /** * Converts number to corner orientations * @param num Number representing orientations * @returns Array of 8 orientations */ private static numberToCornerOri; /** * Converts edge orientations to a number (base 2) * @param orientations Array of 11 orientations (12th is determined by others) * @returns Number representing orientations */ private static edgeOriToNumber; /** * Converts number to edge orientations * @param num Number representing orientations * @returns Array of 12 orientations */ private static numberToEdgeOri; /** * Converts cube state to a unique number * @param ca Corner array from CubieCube * @param ea Edge array from CubieCube * @returns BigInt representing the unique cube state (0 to TOTAL_STATES-1) */ static cubeStateToNumber(ca: number[], ea: number[]): bigint; /** * Converts a unique number back to cube state * @param cubeNumber BigInt representing the cube state * @returns Object with corner array and edge array */ static numberToCubeState(cubeNumber: bigint): { ca: number[]; ea: number[]; }; /** * Converts cube number to hexadecimal string (for storage/display) * @param cubeNumber BigInt cube number * @returns Hex string representation */ static cubeNumberToHex(cubeNumber: bigint): string; /** * Converts hexadecimal string to cube number * @param hex Hex string representation * @returns BigInt cube number */ static hexToCubeNumber(hex: string): bigint; } //# sourceMappingURL=cubenum.d.ts.map