Exemplo n.º 1
0
 internal 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 = Array.BinarySearch(EPermS2R, (char)temps.getEPerm());
         if (idx >= 0)
         {
             return(idx << 4 | k);
         }
     }
     return(0);
 }
Exemplo n.º 2
0
        internal static void initPermSym2Raw()
        {
            CubieCube c     = new CubieCube();
            CubieCube d     = new CubieCube();
            int       count = 0;

            EPermR2S = new char[40320];

            for (int i = 0; i < 40320; i++)
            {
                if (EPermR2S[i] != 0)
                {
                    continue;
                }
                c.setEPerm(i);
                for (int s = 0; s < 16; s++)
                {
                    EdgeConjugate(c, s, d);
                    int idx = d.getEPerm();
                    if (idx == i)
                    {
                        SymStatePerm[count] |= (char)(1 << s);
                    }
                    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);
                    if (s == 0)
                    {
                        Perm2Comb[count] = (byte)(494 - (a & 0x1ff));
                    }
                }
                EPermS2R[count++] = (char)i;
            }
            if (count != 2768)
            {
                throw new Exception("Unexpected count value");
            }
        }