Пример #1
0
 public static Cube4 RandomCube4(bool corner = true, bool wing = true, bool xcenter = true)
 {
     Tools.SetNPerm(corner ? Tools.rd.Next(40320) : 0, 8, out int[] cp);
     Tools.SetNTwist(corner ? Tools.rd.Next(2187) : 0, 8, out int[] co);
     for (int i = 0; i < 8; i++)
     {
         cp[i] = cp[i] * 3 + co[i];
     }
     int[] w, xc;
     if (wing)
     {
         w = Wing.Random();
     }
     else
     {
         w = new int[24]; for (int i = 0; i < 24; i++)
         {
             w[i] = i;
         }
     }
     if (xcenter)
     {
         xc = XCenter.Random();
     }
     else
     {
         xc = new int[24]; for (int i = 0; i < 24; i++)
         {
             xc[i] = i >> 2;
         }
     }
     return(new Cube4(w, cp, xc));
 }
Пример #2
0
        // Must call Reset() before this in advance
        public Cube4 GetCube4()
        {
            if (!Exist())
            {
                return(null);
            }
            double a = rd.NextDouble(), b = rd.NextDouble();
            var    c = rd.NextDouble() < CF ? Corner.odd[Array.FindIndex(OCPs, x => x > a * OCP)] :
                       Corner.even[Array.FindIndex(ECPs, x => x > a * ECP)];
            var w  = Wing.list[Array.FindIndex(WPs, x => x > b)];
            var xc = XCenter.GetInstance(xcLimit);

            return(new Cube4(c.GetInstance(), w.GetInstance(), xc));
        }
Пример #3
0
        public void Reset()
        {
            int  index = 0;
            long ECC = 0, OCC = 0;

            foreach (var x in Corner.odd)
            {
                OCPs[index++] = (OCC += cornerParity.Test(true) && cornerLimit.Test(x) ? x.Count : 0) * 2.0 / Corner.Sum;
            }
            OCP = OCPs[OCPs.Length - 1];
            CC  = index = 0;
            foreach (var x in Corner.even)
            {
                ECPs[index++] = (ECC += cornerParity.Test(false) && cornerLimit.Test(x) ? x.Count : 0) * 2.0 / Corner.Sum;
            }
            ECP = ECPs[ECPs.Length - 1];
            CC  = OCC + ECC;
            CP  = ECP + OCP;
            CF  = (double)OCC / CC;

            WC = 0;
            double OWC = 0, wingSum = (double)Wing.Sum;

            for (index = 0; index < WPs.Length; ++index)
            {
                if (wingLimit.Test(Wing.list[index]))
                {
                    WPs[index] = (double)(WC += Wing.list[index].Count) / wingSum;
                    if (Wing.list[index].Parity == 1)
                    {
                        OWC += (double)Wing.list[index].Count / wingSum;
                    }
                }
            }
            WP = WPs[WPs.Length - 1];
            WF = OWC / (double)WC;

            XCC = XCenter.GetCount(xcLimit);
            XCP = (double)XCC / XCenter.Sum;
        }
Пример #4
0
 public Cube4(int[] c, int[] w, int[] xc)
 {
     corner  = new Corner(c);
     wing    = new Wing(w);
     xcenter = new XCenter(xc);
 }
Пример #5
0
 public Cube4()
 {
     corner  = new Corner();
     wing    = new Wing();
     xcenter = new XCenter();
 }