Exemple #1
0
        public bool Init3()
        {
            c2.Copy(c1);
            for (int i = 0; i < Length2; i++)
            {
                c2.Move(move2[i]);
            }
            if (!c2.CheckEdge())
            {
                return(false);
            }
            int eparity = e12.Set(c2.GetEdge());

            ct3.Set(c2.GetCenter(), eparity ^ c2.GetCorner().GetParity());
            int ct = ct3.Getct();

            _ = e12.Get(10);
            int prun = Edge3.Getprun(e12.Getsym());

            if (arr2[arr2idx] == null)
            {
                arr2[arr2idx] = new FullCube(c2);
            }
            else
            {
                arr2[arr2idx].Copy(c2);
            }
            arr2[arr2idx].value   = Length1 + Length2 + Math.Max(prun, Center3.prun[ct]);
            arr2[arr2idx].Length2 = Length2;
            arr2idx++;

            return(arr2idx == arr2.Length);
        }
Exemple #2
0
 public string Solution(string facelet)
 {
     sbyte[] f = new sbyte[96];
     for (int i = 0; i < 96; i++)
     {
         f[i] = (sbyte)"urfdlb".IndexOf(facelet[i]);
     }
     c = new FullCube(f);
     DoSearch();
     return(solution);
 }
Exemple #3
0
        public bool Init2(int sym, int _)
        {
            c1.Copy(c);
            for (int i = 0; i < Length1; i++)
            {
                c1.Move(move1[i]);
            }

            switch (finish[sym])
            {
            case 0:
                c1.Move(fx1);
                c1.Move(bx3);
                move1[Length1]     = fx1;
                move1[Length1 + 1] = bx3;
                add1 = true;
                sym  = 19;
                break;

            case 12869:
                c1.Move(ux1);
                c1.Move(dx3);
                move1[Length1]     = ux1;
                move1[Length1 + 1] = dx3;
                add1 = true;
                sym  = 34;
                break;

            case 735470:
                add1 = false;
                sym  = 0;
                break;
            }
            ct2.Set(c1.GetCenter(), c1.GetEdge().GetParity());
            int s2ct = ct2.Getct();
            int s2rl = ct2.Getrl();
            int ctp  = ctprun[s2ct * 70 + s2rl];

            c1.value   = ctp + Length1;
            c1.Length1 = Length1;
            c1.add1    = add1;
            c1.sym     = sym;
            p1SolsCnt++;

            FullCube next;

            if (p1sols.Count < PHASE2_ATTEMPTS)
            {
                next = new FullCube(c1);
            }
            else
            {
                next = p1sols.Pop();
                if (next.value > c1.value)
                {
                    next.Copy(c1);
                }
            }
            p1sols.Push(next);

            return(p1SolsCnt == PHASE1_SOLUTIONS);
        }
Exemple #4
0
 public void Calc(FullCube s)
 {
     c = s;
     DoSearch();
 }
Exemple #5
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;
        }
Exemple #6
0
 public string Solve(int[] moveseq)
 {
     c = new FullCube(moveseq);
     DoSearch();
     return(solution);
 }
Exemple #7
0
 public string RandomState(Random r)
 {
     c = new FullCube(r);
     DoSearch();
     return(solution);
 }