Пример #1
0
        public static void InitRaw2Sym()
        {
            Edge3 e = new Edge3();

            sbyte[] occ   = new sbyte[11880 / 8];
            int     count = 0;

            for (int i = 0; i < 11880; i++)
            {
                if ((occ[i >> 3] & (1 << (i & 7))) == 0) //>
                {
                    e.Set(i * factX[8]);
                    for (int j = 0; j < 8; j++)
                    {
                        int idx = e.Get(4);
                        if (idx == i)
                        {
                            symstate[count] |= (char)(1 << j);
                        }
                        occ[idx >> 3] |= (sbyte)(1 << (idx & 7));
                        raw2sym[idx]   = count << 3 | syminv[j];
                        e.Rot(0);
                        if (j % 2 == 1)
                        {
                            e.Rot(1);
                            e.Rot(2);
                        }
                    }
                    sym2raw[count++] = i;
                }
            }
            //assert count == 1538;
        }
Пример #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);
            }
        }