Exemple #1
0
        public static (ImmutableArray <ushort> classIndex, ImmutableArray <byte> sym, ImmutableArray <uint> rep) Create()
        {
            var flipsliceClassidx = new ushort[Definitions.NFlip * Definitions.NSlice];
            var flipsliceSym      = new byte[Definitions.NFlip * Definitions.NSlice];
            var flipsliceRep      = new uint[Definitions.NFlipsliceClass];

            Array.Fill(flipsliceClassidx, ushort.MaxValue); //todo find a way around this

            //TODO check what actual types should be
            ushort classIndex = 0;
            var    cc         = SolvedCube.Instance.Clone();

            for (ushort slc = 0; slc < Definitions.NSlice; slc++)
            {
                cc.set_slice(slc);

                for (var flip = 0; flip < Definitions.NFlip; flip++)
                {
                    cc.set_flip(flip);
                    var idx = Convert.ToUInt32(Definitions.NFlip * slc + flip);
                    if ((idx + 1) % 4000 == 0)
                    {
                        Console.Write(".");
                    }
                    if ((idx + 1) % 320000 == 0)
                    {
                        Console.WriteLine("");
                    }
                    if (flipsliceClassidx[idx] != ushort.MaxValue)
                    {
                        continue;
                    }

                    flipsliceClassidx[idx]   = classIndex;
                    flipsliceSym[idx]        = 0;
                    flipsliceRep[classIndex] = idx;

                    for (byte s = 0; s < Definitions.NSymD4H; s++)
                    {
                        // conjugate represented by all 16 symmetries
                        var ss = Inverse.GetCube(s).Clone();
                        ss.EdgeMultiply(cc);
                        ss.EdgeMultiply(Basic.Cubes[s]);
                        var idxNew = Definitions.NFlip * ss.get_slice() + ss.get_flip();
                        if (flipsliceClassidx[idxNew] == ushort.MaxValue)
                        {
                            flipsliceClassidx[idxNew] = classIndex;
                            flipsliceSym[idxNew]      = s;
                        }
                    }


                    classIndex += 1;
                }
            }

            return(flipsliceClassidx.ToImmutableArray(), flipsliceSym.ToImmutableArray(), flipsliceRep.ToImmutableArray());
        }
        public static (ImmutableArray <ushort> corner_classidx, ImmutableArray <byte> corner_sym, ImmutableArray <ushort> corner_rep) Create()
        {
            ushort[] cornerRep;
            byte[]   cornerSym;
            ushort[] cornerClassidx;

            cornerClassidx = new ushort[Definitions.NCorners];
            Array.Fill(cornerClassidx, ushort.MaxValue);
            cornerSym = new byte[Definitions.NCorners];
            cornerRep = new ushort[Definitions.NCornersClass];


            ushort classidx = 0;
            var    cc       = SolvedCube.Instance.Clone();

            for (ushort cp = 0; cp < Definitions.NCorners; cp++)
            {
                cc.set_corners(cp);
                if ((cp + 1) % 8000 == 0)
                {
                    Console.Write(".");
                }
                if (cornerClassidx[cp] == ushort.MaxValue)
                {
                    cornerClassidx[cp]  = classidx;
                    cornerSym[cp]       = 0;
                    cornerRep[classidx] = cp;
                }
                else
                {
                    continue;
                }

                for (byte s = 0; s < Definitions.NSymD4H; s++)
                {
                    // conjugate represented by all 16 symmetries
                    var ss = Inverse.GetCube(s).Clone();
                    ss.CornerMultiply(cc);
                    ss.CornerMultiply(Basic.Cubes[s]); //s^-1*cc*s
                    var cpNew = ss.GetCorners();
                    if (cornerClassidx[cpNew] == ushort.MaxValue)
                    {
                        cornerClassidx[cpNew] = classidx;
                        cornerSym[cpNew]      = s;
                    }
                }
                classidx += 1;
            }

            return(cornerClassidx.ToImmutableArray(), cornerSym.ToImmutableArray(), cornerRep.ToImmutableArray());
        }
        private static Move[,] Generate()
        {
            var conjMove = new Move[Definitions.NMove, Definitions.NSym];

            for (var s = 0; s < 0 + Definitions.NSym; s++)
            {
                foreach (var m in Extensions.GetEnumValues <Move>())
                {
                    var ss = Basic.Cubes[s].Clone();
                    ss.Multiply(MoveCubes.BasicCubesByMove[m]);
                    ss.Multiply(Inverse.GetCube(s));
                    var move = Extensions.GetEnumValues <Move>().Single(m2 => ss.Equals(MoveCubes.BasicCubesByMove[m2]));
                    conjMove[(int)m, s] = move;
                }
            }

            return(conjMove);
        }