MCPcopy Create free account
hub / github.com/MeigenChou/DCTimer-Android / Cube2Face

Class Cube2Face

app/src/main/java/solver/Cube2Face.java:5–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import static solver.Utils.suff;
4
5public class Cube2Face {
6 private static short[][] facemv = new short[10626][3];
7 private static byte[] prun = new byte[10626];
8 private static int[] seq = new int[7];
9 private static int[] solved = {1819, 0, 4844, 69, 494, 10625};
10
11 private static void init() {
12 int[] arr = new int[24];
13 for (int i = 0; i < 10626; i++) {
14 prun[i] = -1;
15 for (int j = 0; j < 3; j++) {
16 Utils.idxToComb(arr, i, 4, 24);
17 switch (j) {
18 case 0: //U
19 Utils.circle(arr, 0, 2, 3, 1);
20 Utils.circle(arr, 4, 20, 16, 8);
21 Utils.circle(arr, 5, 21, 17, 9);
22 break;
23 case 1: //R
24 Utils.circle(arr, 4, 6, 7, 5);
25 Utils.circle(arr, 1, 9, 13, 22);
26 Utils.circle(arr, 3, 11, 15, 20);
27 break;
28 case 2: //F
29 Utils.circle(arr, 8, 10, 11, 9);
30 Utils.circle(arr, 2, 19, 13, 4);
31 Utils.circle(arr, 3, 17, 12, 6);
32 break;
33 }
34 facemv[i][j] = (short) Utils.combToIdx(arr, 4, 24);
35 }
36 }
37 for (int i = 0; i < 6; i++) prun[solved[i]] = 0;
38 Utils.createPrun(prun, 5, facemv, 3);
39 }
40
41 static {
42 init();
43 }
44
45 private static boolean search(int face, int d, int lm) {
46 if (d == 0) return prun[face] == 0;
47 if (prun[face] > d) return false;
48 for (int i = 0; i < 3; i++)
49 if (i != lm) {
50 int x = face;
51 for (int j = 0; j < 3; j++) {
52 x = facemv[x][i];
53 if (search(x, d - 1, i)) {
54 seq[d] = i * 3 + j;
55 return true;
56 }
57 }
58 }
59 return false;
60 }
61
62 private static String[] color = {"D: ", "U: ", "L: ", "R: ", "F: ", "B: "};

Callers

nothing calls this directly

Calls 1

initMethod · 0.95

Tested by

no test coverage detected