Пример #1
0
        public static SeedSearchResult GetFirstSeed(uint ec, uint pid, int[] ivs, SeedCheckResults mode)
        {
            var   seeds      = GetSeeds(ec, pid);
            bool  hasClosest = false;
            ulong closest    = 0;

            foreach (var seed in seeds)
            {
                // Verify the IVs; at most 5 can match
                for (int i = 1; i <= 5; i++) // fixed IV count
                {
                    if (IsMatch(seed, ivs, i))
                    {
                        return(new SeedSearchResult(Z3SearchResult.Success, seed, i, mode));
                    }
                }
                hasClosest = true;
                closest    = seed;
            }

            if (hasClosest)
            {
                return(new SeedSearchResult(Z3SearchResult.SeedMismatch, closest, 0, mode));
            }
            return(SeedSearchResult.None);
        }
Пример #2
0
        public static void GetShinyFrames(ulong seed, out int[] frames, out uint[] type, out List <uint[, ]> IVs, SeedCheckResults mode)
        {
            int shinyindex = 0;

            frames = new int[3];
            type   = new uint[3];
            IVs    = new List <uint[, ]>();
            bool foundStar   = false;
            bool foundSquare = false;

            var rng = new Xoroshiro128Plus(seed);

            for (int i = 0; ; i++)
            {
                uint _         = (uint)rng.NextInt(0xFFFFFFFF); // EC
                uint SIDTID    = (uint)rng.NextInt(0xFFFFFFFF);
                uint PID       = (uint)rng.NextInt(0xFFFFFFFF);
                var  shinytype = GetShinyType(PID, SIDTID);

                // If we found a shiny, record it and return if we got everything we wanted.
                if (shinytype != 0)
                {
                    if (shinytype == 1)
                    {
                        foundStar = true;
                    }
                    else if (shinytype == 2)
                    {
                        foundSquare = true;
                    }

                    if (shinyindex == 0 || mode == SeedCheckResults.FirstThree || (foundStar && foundSquare))
                    {
                        frames[shinyindex] = i;
                        type[shinyindex]   = shinytype;
                        GetShinyIVs(rng, out uint[,] frameIVs);
                        IVs.Add(frameIVs);

                        shinyindex++;
                    }

                    if (mode == SeedCheckResults.ClosestOnly || (mode == SeedCheckResults.FirstStarAndSquare && foundStar && foundSquare) || shinyindex >= 3)
                    {
                        return;
                    }
                }

                // Get the next seed, and reset for the next iteration
                rng  = new Xoroshiro128Plus(seed);
                seed = rng.Next();
                rng  = new Xoroshiro128Plus(seed);
            }
        }
Пример #3
0
        public static IList <SeedSearchResult> GetAllSeeds(uint ec, uint pid, int[] ivs, SeedCheckResults mode)
        {
            var result = new List <SeedSearchResult>();
            var seeds  = GetSeeds(ec, pid);

            foreach (var seed in seeds)
            {
                // Verify the IVs; at most 5 can match
                bool added = false;
                for (int i = 1; i <= 5; i++) // fixed IV count
                {
                    if (IsMatch(seed, ivs, i))
                    {
                        result.Add(new SeedSearchResult(Z3SearchResult.Success, seed, i, mode));
                        added = true;
                    }
                }
                if (!added)
                {
                    result.Add(new SeedSearchResult(Z3SearchResult.SeedMismatch, seed, 0, mode));
                }
            }

            if (result.Count == 0)
            {
                result.Add(SeedSearchResult.None);
            }
            else if (result.Any(z => z.Type == Z3SearchResult.Success))
            {
                result.RemoveAll(z => z.Type != Z3SearchResult.Success);
            }
            return(result);
        }