int getTwistSym() { if (TwistR2S != null) { return TwistR2S[getTwist()]; } if (temps == null) { temps = new CubieCube(); } for (int k = 0; k < 16; k += 2) { CornConjugate(this, SymInv[k], temps); int idx = Util.binarySearch(TwistS2R, temps.getTwist()); if (idx != 0xffff) { return (idx << 3) | (k >> 1); } } return 0; }
int getCPermSym() { if (EPermR2S != null) { int idx = EPermR2S[getCPerm()]; idx ^= e2c[idx & 0x0f]; return idx; } if (temps == null) { temps = new CubieCube(); } for (int k = 0; k < 16; k++) { CornConjugate(this, SymInv[k], temps); int idx = Util.binarySearch(EPermS2R, temps.getCPerm()); if (idx != 0xffff) { return (idx << 4) | k; } } return 0; }
static void initTwistSym2Raw() { CubieCube c = new CubieCube(); CubieCube d = new CubieCube(); int[] occ = new int[2187 / 32 + 1]; int count = 0; for (int i = 0; i < 2187 / 32 + 1; occ[i++] = 0) ; TwistR2S = new char[2187]; for (int i = 0; i < 2187; i++) { if ((occ[i >> 5] & (1 << (i & 0x1f))) == 0) { c.setTwist(i); for (int s = 0; s < 16; s += 2) { CornConjugate(c, s, d); int idx = d.getTwist(); if (idx == i) { SymStateTwist[count] |= 1 << (s >> 1); } occ[idx >> 5] |= 1 << (idx & 0x1f); TwistR2S[idx] = (char) ((count << 3) | (s >> 1)); } TwistS2R[count++] = (char) i; } } }
static void initSym() { CubieCube c = new CubieCube(); CubieCube d = new CubieCube(); CubieCube t; CubieCube f2 = new CubieCube(28783, 0, 259268407, 0); CubieCube u4 = new CubieCube(15138, 0, 119765538, 7); CubieCube lr2 = new CubieCube(5167, 0, 83473207, 0); lr2.co = new byte[] {3, 3, 3, 3, 3, 3, 3, 3}; for (int i = 0; i < 16; i++) { CubeSym[i] = new CubieCube(c); CornMult(c, u4, d); EdgeMult(c, u4, d); t = d; d = c; c = t; if (i % 4 == 3) { CornMult(c, lr2, d); EdgeMult(c, lr2, d); t = d; d = c; c = t; } if (i % 8 == 7) { CornMult(c, f2, d); EdgeMult(c, f2, d); t = d; d = c; c = t; } } for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { CornMult(CubeSym[i], CubeSym[j], c); for (int k = 0; k < 16; k++) { if (CubeSym[k].cp[0] == c.cp[0] && CubeSym[k].cp[1] == c.cp[1] && CubeSym[k].cp[2] == c.cp[2]) { SymMult[i][j] = k; if (k == 0) { SymInv[i] = j; } break; } } } } for (int j = 0; j < 18; j++) { for (int s = 0; s < 16; s++) { CornConjugate(moveCube[j], SymInv[s], c); CONTINUE: for (int m = 0; m < 18; m++) { for (int i = 0; i < 8; i += 2) { if (c.cp[i] != moveCube[m].cp[i]) { continue CONTINUE; } } SymMove[s][j] = m; break; } } } for (int j = 0; j < 10; j++) { for (int s = 0; s < 16; s++) { SymMoveUD[s][j] = Util.std2ud[SymMove[s][Util.ud2std[j]]]; } } for (int j = 0; j < 8; j++) { for (int s = 0; s < 8; s++) { Sym8Mult[j][s] = SymMult[j << 1][s << 1] >> 1; Sym8MultInv[j][s] = SymMult[j << 1][SymInv[s << 1]] >> 1; } } for (int j = 0; j < 18; j++) { for (int s = 0; s < 8; s++) { Sym8Move[s][j] = SymMove[s << 1][j]; } } }