@speedcubing/snowcone
v0.0.1
Published
A Rubik's cube scrambler API for Node.js.
Downloads
3
Readme
SCO Snowcone
A NxN Rubik's cube scrambling library for Node.js
Scrambling
You can scramble a cube using the snowcone.generateScramble
method:
const snowcone = require('@speedcubing/snowcone');
snowcone.generateScramble(30) // Generate scramble with 30 moves
.then((result) => {
console.log(result.scramble);
});
Synchronous Generation
To generate scrambles synchronously, you can use the snowcone.generateScrambleSync
function.
const snowcone = require('@speedcubing/snowcone');
const result = generateScrambleSync(30); // Generate a scramble with 30 moves
console.log(result.scramble);
Arguments
snowcone.generateScramble(count: number, size: number = 3, hash?: string);
As you can see, the second argument, size
, is optional and defaults to a 3x3 Rubik's cube.
If, for example, you want to generate a scramble for a 4x4 Rubik's cube, you can change this argument to 4:
snowcone.generateScramble(30, 4);
The first argument is the move count of the scramble, and the second argument is the size of the cube.
The same arguments apply to the generateScrambleSync
method.
Seeding
If you want to generate a scramble with your own seed
, you can provide a 3rd argument, which is a string (keep in mind, you must provide a size
argument to use a custom seed):
scramble.generateScramble(30, 3, 'my custom seed');
Verification
You can verify if a scramble was generated by Snowcone with the verifyScramble
and verifyScrambleSync
methods.
const scrambled = require('scrambled');
const scramble = scramble.generateScrambleSync(30);
scrambled.verifyScramble(scramble.token, scramble.scramble, scramble.size)
.then((result) => {
console.log(result); // true or false
});