Пример #1
0
 void rotate(int r) {
   for (int j = 0; j < r; j++) {
     rot(0);
     if (j % 2 == 1) rot(1);
     if (j % 8 == 7) rot(2);
     if (j % 16 == 15) rot(3);
   }
 }
Пример #2
0
 int getsym() {
   if (raw2sym != null) {
     return raw2sym[get()];
   }
   for (int j = 0; j < 48; j++) {
     int cord = raw2sym(get());
     if (cord != -1) return cord * 64 + j;
     rot(0);
     if (j % 2 == 1) rot(1);
     if (j % 8 == 7) rot(2);
     if (j % 16 == 15) rot(3);
   }
   System.out.print('e');
   return -1;
 }
Пример #3
0
 static int getSolvedSym(CenterCube cube) {
   Center1 c = new Center1(cube.ct);
   for (int j = 0; j < 48; j++) {
     boolean check = true;
     for (int i = 0; i < 24; i++) {
       if (c.ct[i] != i / 4) {
         check = false;
         break;
       }
     }
     if (check) {
       return j;
     }
     c.rot(0);
     if (j % 2 == 1) c.rot(1);
     if (j % 8 == 7) c.rot(2);
     if (j % 16 == 15) c.rot(3);
   }
   return -1;
 }
Пример #4
0
 static void initSym2Raw() {
   Center1 c = new Center1();
   int[] occ = new int[735471 / 32 + 1];
   int count = 0;
   for (int i = 0; i < 735471; i++) {
     if ((occ[i >>> 5] & (1 << (i & 0x1f))) == 0) {
       c.set(i);
       for (int j = 0; j < 48; j++) {
         int idx = c.get();
         occ[idx >>> 5] |= (1 << (idx & 0x1f));
         if (raw2sym != null) {
           raw2sym[idx] = count << 6 | syminv[j];
         }
         c.rot(0);
         if (j % 2 == 1) c.rot(1);
         if (j % 8 == 7) c.rot(2);
         if (j % 16 == 15) c.rot(3);
       }
       sym2raw[count++] = i;
     }
   }
   assert count == 15582;
 }
Пример #5
0
  static void initSym() {
    Center1 c = new Center1();
    for (byte i = 0; i < 24; i++) {
      c.ct[i] = i;
    }
    Center1 d = new Center1(c.ct);
    Center1 e = new Center1(c.ct);
    Center1 f = new Center1(c.ct);

    for (int i = 0; i < 48; i++) {
      for (int j = 0; j < 48; j++) {
        for (int k = 0; k < 48; k++) {
          if (c.equals(d)) {
            symmult[i][j] = k;
            if (k == 0) {
              syminv[i] = j;
            }
          }
          d.rot(0);
          if (k % 2 == 1) d.rot(1);
          if (k % 8 == 7) d.rot(2);
          if (k % 16 == 15) d.rot(3);
        }
        c.rot(0);
        if (j % 2 == 1) c.rot(1);
        if (j % 8 == 7) c.rot(2);
        if (j % 16 == 15) c.rot(3);
      }
      c.rot(0);
      if (i % 2 == 1) c.rot(1);
      if (i % 8 == 7) c.rot(2);
      if (i % 16 == 15) c.rot(3);
    }

    for (int i = 0; i < 48; i++) {
      c.set(e);
      c.rotate(syminv[i]);
      for (int j = 0; j < 36; j++) {
        d.set(c);
        d.move(j);
        d.rotate(i);
        for (int k = 0; k < 36; k++) {
          f.set(e);
          f.move(k);
          if (f.equals(d)) {
            symmove[i][j] = k;
            break;
          }
        }
      }
    }

    c.set(0);
    for (int i = 0; i < 48; i++) {
      finish[syminv[i]] = c.get();
      c.rot(0);
      if (i % 2 == 1) c.rot(1);
      if (i % 8 == 7) c.rot(2);
      if (i % 16 == 15) c.rot(3);
    }
  }