Esempio n. 1
0
        public static void InitMvrot()
        {
            Edge3 e = new Edge3();

            for (int m = 0; m < 20; m++)
            {
                for (int r = 0; r < 8; r++)
                {
                    e.Set(0);
                    e.Move(m);
                    e.Rotate(r);
                    for (int i = 0; i < 12; i++)
                    {
                        mvrot[m << 3 | r, i] = e.edge[i];
                    }
                    e.Std();
                    for (int i = 0; i < 12; i++)
                    {
                        mvroto[m << 3 | r, i] = e.temp[i];
                    }
                }
            }
        }
Esempio n. 2
0
        public static void CreatePrun()
        {
            Edge3 e = new Edge3();
            Edge3 f = new Edge3();
            Edge3 g = new Edge3();

            for (int i = 0; i < eprun.Length; i++)
            {
                eprun[i] = -1;
            }
            int depth = 0;

            done = 1;
            SetPruning(eprun, 0, 0);

            while (done != N_EPRUN)
            {
                bool inv    = depth > 9;
                int  depm3  = depth % 3;
                int  dep1m3 = (depth + 1) % 3;
                int  find   = inv ? 0x3 : depm3;
                int  chk    = inv ? depm3 : 0x3;

                if (depth >= MAX_DEPTH - 1)
                {
                    break;
                }

                for (int i_ = 0; i_ < N_EPRUN; i_ += 16)
                {
                    int val = eprun[i_ >> 4];
                    if (!inv && val == -1)
                    {
                        continue;
                    }
                    for (int i = i_, end = i_ + 16; i < end; i++, val >>= 2)
                    {
                        if ((val & 0x3) != find)
                        {
                            continue;
                        }
                        int symcord1 = i / N_RAW;
                        int cord1    = sym2raw[symcord1];
                        int cord2    = i % N_RAW;
                        e.Set(cord1 * N_RAW + cord2);

                        for (int m = 0; m < 17; m++)
                        {
                            int cord1x    = Getmvrot(e.edge, m << 3, 4);
                            int symcord1x = raw2sym[cord1x];
                            int symx      = symcord1x & 0x7;
                            symcord1x >>= 3;
                            int cord2x = Getmvrot(e.edge, m << 3 | symx, 10) % N_RAW;
                            int idx    = symcord1x * N_RAW + cord2x;
                            if (GetPruning(eprun, idx) != chk)
                            {
                                continue;
                            }
                            SetPruning(eprun, inv ? i : idx, dep1m3);
                            done++;
                            // if ((done & 0x3ffff) == 0) {
                            //  System.out.print(string.format("%d\r", done));
                            // }
                            if (inv)
                            {
                                break;
                            }
                            char symState = symstate[symcord1x];
                            if (symState == 1)
                            {
                                continue;
                            }
                            f.Set(e);
                            f.Move(m);
                            f.Rotate(symx);
                            for (int j = 1; (symState >>= 1) != 0; j++)
                            {
                                if ((symState & 1) != 1)
                                {
                                    continue;
                                }
                                g.Set(f);
                                g.Rotate(j);
                                int idxx = symcord1x * N_RAW + g.Get(10) % N_RAW;
                                if (GetPruning(eprun, idxx) == chk)
                                {
                                    SetPruning(eprun, idxx, dep1m3);
                                    done++;
                                    // if ((done & 0x3ffff) == 0) {
                                    //  System.out.print(string.format("%d\r", done));
                                    // }
                                }
                            }
                        }
                    }
                }
                depth++;
                //System.out.println(depth + "\t" + done);
            }
        }