Example #1
0
 static void initPermSym2Raw() {
   CubieCube c = new CubieCube();
   CubieCube d = new CubieCube();
   int[] occ = new int[40320 / 32];
   int count = 0;
   for (int i = 0; i < 40320 / 32; occ[i++] = 0) ;
   EPermR2S = new char[40320];
   for (int i = 0; i < 40320; i++) {
     if ((occ[i >> 5] & (1 << (i & 0x1f))) == 0) {
       c.setEPerm(i);
       for (int s = 0; s < 16; s++) {
         EdgeConjugate(c, s, d);
         int idx = d.getEPerm();
         if (idx == i) {
           SymStatePerm[count] |= 1 << s;
         }
         occ[idx >> 5] |= 1 << (idx & 0x1f);
         int a = d.getU4Comb();
         int b = d.getD4Comb() >> 9;
         int m = 494 - (a & 0x1ff) + (a >> 9) * 70 + b * 1680;
         MtoEPerm[m] = EPermR2S[idx] = (char) (count << 4 | s);
       }
       EPermS2R[count++] = (char) i;
     }
   }
 }
Example #2
0
 static void initFlipSym2Raw() {
   CubieCube c = new CubieCube();
   CubieCube d = new CubieCube();
   int[] occ = new int[2048 >> 5];
   int count = 0;
   for (int i = 0; i < 2048 >> 5; occ[i++] = 0) ;
   FlipR2S = new char[2048];
   for (int i = 0; i < 2048; i++) {
     if ((occ[i >> 5] & (1 << (i & 0x1f))) == 0) {
       c.setFlip(i);
       for (int s = 0; s < 16; s += 2) {
         EdgeConjugate(c, s, d);
         int idx = d.getFlip();
         if (idx == i) {
           SymStateFlip[count] |= 1 << (s >> 1);
         }
         occ[idx >> 5] |= 1 << (idx & 0x1f);
         FlipR2S[idx] = (char) ((count << 3) | (s >> 1));
       }
       FlipS2R[count++] = (char) i;
     }
   }
 }
Example #3
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;
     }
   }
 }
Example #4
0
 int getEPermSym() {
   if (EPermR2S != null) {
     return EPermR2S[getEPerm()];
   }
   if (temps == null) {
     temps = new CubieCube();
   }
   for (int k = 0; k < 16; k++) {
     EdgeConjugate(this, SymInv[k], temps);
     int idx = Util.binarySearch(EPermS2R, temps.getEPerm());
     if (idx != 0xffff) {
       return (idx << 4) | k;
     }
   }
   return 0;
 }
Example #5
0
 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;
 }
Example #6
0
 int getFlipSym() {
   if (FlipR2S != null) {
     return FlipR2S[getFlip()];
   }
   if (temps == null) {
     temps = new CubieCube();
   }
   for (int k = 0; k < 16; k += 2) {
     EdgeConjugate(this, SymInv[k], temps);
     int idx = Util.binarySearch(FlipS2R, temps.getFlip());
     if (idx != 0xffff) {
       return (idx << 3) | (k >> 1);
     }
   }
   return 0;
 }
Example #7
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;
 }
Example #8
0
  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];
      }
    }
  }