-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
53 lines (40 loc) · 1.37 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// import {
// Cube,
// Parser,
// StandardMoves,
// JapaneseColors,
// Sledgehammer,
// } from "./cube3";
let {
Cube,
StandardMoves,
JapaneseColors,
Parser,
Sledgehammer,
} = require("./cube3");
let myCube = new Cube(StandardMoves); // Add a move set to the cube
myCube.init(JapaneseColors); // Initialize the cube with a specific color scheme
// Turn the cube with the moves that you have defined...
myCube.R(1); // Normal R move
// Make sure your cube has changed...
console.log(myCube.flatten());
myCube.R(-1); // Inverse R move (R')
// That's cool, but what if we want to parse it from a string?
// No problem.
let parser = new Parser(myCube); // Give your parser the cube object
parser.run("R U R' U'"); // Just do this!
parser.run("U R U' R'"); // Or this...(inverse of above)
console.log(myCube.flatten()); // Should be solved...:)
// But what if we want to define something to use later? No problem.
parser.register({
name: "checker",
algorithm: "R2 L2 U2 D2 F2 B2",
});
// Execute with the same run function. Just put a "$" in front of the name!
parser.run("$checker");
parser.run("$checker"); // and undo that...
// In order to register a set of algorithms, use the registerSet function.
// You can use a pre-defined set of algorithms like the Sledgehammer!
parser.registerSet(Sledgehammer);
parser.run("$sledgehammer");
console.log(myCube.flatten()); // Check it out!