Ejemplo n.º 1
0
        public static int GetSolvedSym(CenterCube cube)
        {
            Center1 c = new Center1(cube.ct);

            for (int j = 0; j < 48; j++)
            {
                bool check = true;
                for (int i = 0; i < 24; i++)
                {
                    if (c.ct[i] != FullCube.centerFacelet[i] / 16)
                    {
                        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);
        }
Ejemplo n.º 2
0
 public void Set(Center1 c)
 {
     for (int i = 0; i < 24; i++)
     {
         this.ct[i] = c.ct[i];
     }
 }
Ejemplo n.º 3
0
        public static void CreateMoveTable()
        {
            //System.out.println("Create Phase1 Center Move Table...");
            Center1 c = new Center1();
            Center1 d = new Center1();

            for (int i = 0; i < 15582; i++)
            {
                d.Set(sym2raw[i]);
                for (int m = 0; m < 36; m++)
                {
                    c.Set(d);
                    c.Move(m);
                    ckmv[i, m] = c.Getsym();
                }
            }
        }
Ejemplo n.º 4
0
        public 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;
        }
Ejemplo n.º 5
0
        public static void InitSym()
        {
            Center1 c = new Center1();

            for (sbyte 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);
                }
            }
        }
Ejemplo n.º 6
0
        public void DoSearch()
        {
            solution = "";
            int ud     = new Center1(c.GetCenter(), 0).Getsym();
            int fb     = new Center1(c.GetCenter(), 1).Getsym();
            int rl     = new Center1(c.GetCenter(), 2).Getsym();
            int udprun = csprun[ud >> 6];
            int fbprun = csprun[fb >> 6];
            int rlprun = csprun[rl >> 6];

            p1SolsCnt = 0;
            arr2idx   = 0;
            p1sols.Clear();

            for (Length1 = Math.Min(Math.Min(udprun, fbprun), rlprun); Length1 < 100; Length1++)
            {
                if (rlprun <= Length1 && Search1(rl >> 6, rl & 0x3f, Length1, -1, 0) || //>
                    udprun <= Length1 && Search1(ud >> 6, ud & 0x3f, Length1, -1, 0) ||     //>
                    fbprun <= Length1 && Search1(fb >> 6, fb & 0x3f, Length1, -1, 0))        //>
                {
                    break;
                }
            }

            FullCube[] p1SolsArr = p1sols.ToArray();
            Array.Sort(p1SolsArr);//, 0, p1SolsArr.Length

            int MAX_Length2 = 9;
            int Length12;

            do
            {
                bool out1 = false;
                for (Length12 = p1SolsArr[0].value; Length12 < 100; Length12++)
                {
                    for (int i = 0; i < p1SolsArr.Length; i++)
                    {
                        if (p1SolsArr[i].value > Length12)
                        {
                            break;
                        }
                        if (Length12 - p1SolsArr[i].Length1 > MAX_Length2)
                        {
                            continue;
                        }
                        c1.Copy(p1SolsArr[i]);
                        ct2.Set(c1.GetCenter(), c1.GetEdge().GetParity());
                        int s2ct = ct2.Getct();
                        int s2rl = ct2.Getrl();
                        Length1 = p1SolsArr[i].Length1;
                        Length2 = Length12 - p1SolsArr[i].Length1;

                        if (Search2(s2ct, s2rl, Length2, 28, 0))
                        {
                            out1 = true; break;
                        }
                    }
                    if (out1)
                    {
                        break;
                    }
                }
                MAX_Length2++;
            } while (Length12 == 100);
            Array.Sort(arr2);//, 0, arr2idx
            int Length123, index = 0;
            int solcnt = 0;

            int MAX_Length3 = 13;

            do
            {
                bool out2 = false;
                for (Length123 = arr2[0].value; Length123 < 100; Length123++)
                {
                    for (int i = 0; i < Math.Min(arr2idx, PHASE3_ATTEMPTS); i++)
                    {
                        if (arr2[i].value > Length123)
                        {
                            break;
                        }
                        if (Length123 - arr2[i].Length1 - arr2[i].Length2 > MAX_Length3)
                        {
                            continue;
                        }
                        int eparity = e12.Set(arr2[i].GetEdge());
                        ct3.Set(arr2[i].GetCenter(), eparity ^ arr2[i].GetCorner().GetParity());
                        int ct   = ct3.Getct();
                        int edge = e12.Get(10);
                        int prun = Edge3.Getprun(e12.Getsym());
                        int lm   = 20;

                        if (prun <= Length123 - arr2[i].Length1 - arr2[i].Length2 &&
                            Search3(edge, ct, prun, Length123 - arr2[i].Length1 - arr2[i].Length2, lm, 0))
                        {
                            solcnt++;
                            //					if (solcnt == 5) {
                            index = i;
                            out2  = true;
                            break;
                            //					}
                        }
                    }
                    if (out2)
                    {
                        break;
                    }
                }
                MAX_Length3++;
            } while (Length123 == 100);

            FullCube solcube = new FullCube(arr2[index]);

            Length1 = solcube.Length1;
            Length2 = solcube.Length2;
            int Length = Length123 - Length1 - Length2;

            for (int i = 0; i < Length; i++)
            {
                solcube.Move(move3std[move3[i]]);
            }

            string facelet = solcube.To333Facelet();
            string sol     = search333.Solution(facelet, 21, 1000000, 500, 0);
            int    len333  = search333.Length;

            if (sol.StartsWith("Error"))
            {
                //System.out.println(sol);
                //System.out.println(solcube);
                //System.out.println(facelet);
                throw new Exception();
            }
            int[] sol333 = Tomove(sol);
            for (int i = 0; i < sol333.Length; i++)
            {
                solcube.Move(sol333[i]);
            }

            solution = solcube.GetMovestring(inverse_solution, with_rotation);

            totlen = Length1 + Length2 + Length + len333;
        }