Example #1
0
        public static SOSResult Generate()
        {
            var rt = new SOSResult();

            // First 2 frames for sos call
            rt.Call1 = (byte)(rand % 100);
            rt.Call2 = (byte)(rand % 100);

            // Generate SOS Pokemon (sync, slot, level, held item)
            rt.Sync = rand % 100 >= 50;
            if (Weather)
            {
                rt.Slot = getWeatherSlot(rand % 100);
            }
            if (rt.Slot == 0)
            {
                rt.Slot = getSOSSlot(rand % 100);
            }
            rt.Level = (byte)(rand % 4);
            RNGPool.Advance(1);

            rt.HeldItem = (byte)(rand % 100);

            // Chaining bonus
            while (rt.BumpedIVs.Count(iv => iv) < FlawlessCount)
            {
                rt.BumpedIVs[rand % 6] = true;
            }
            rt.HA = rand % 100 < HARate;

            if (rt.Call1 >= Rate1)
            {
                rt.Advance = 1;
            }
            else if (rt.Call2 >= Rate2)
            {
                rt.Advance = 2;
            }
            else
            {
                rt.Advance = RNGPool.index;
            }
            return(rt);
        }
Example #2
0
        private void Search6()
        {
            MersenneTwister MT        = new MersenneTwister(Seed.Value);
            int             frame     = (int)StartingFrame.Value;
            int             loopcount = (int)MaxResults.Value;
            int             delay     = (int)Delay.Value;
            ulong           N         = (ulong)Range.Value;

            for (int i = 0; i < frame; i++)
            {
                MT.Next();
            }

            RNGPool.CreateBuffer(MT);

            for (int i = 0; i < loopcount; i++, RNGPool.AddNext(MT))
            {
                var f = new Frame_Misc();
                f.Frame    = frame++;
                f.Rand32   = RNGPool.getcurrent;
                f.realtime = i;
                f.st       = RNGPool.getcurrentstate;

                RNGPool.Rewind(0);
                RNGPool.Advance(delay);
                if (filter.Random)
                {
                    f.RandN = (int)((RNGPool.getrand * N) >> 32);
                }
                else if (filter.Pokerus)
                {
                    f.Pokerus = Pokerus6.getStrain();
                }

                if (!filter.check(f))
                {
                    continue;
                }

                Frames.Add(f);
            }
        }
Example #3
0
        private void Search7_FishyTimeline()
        {
            SFMT sfmt        = new SFMT(Seed.Value);
            int  start_frame = (int)Frame_min.Value;
            int  targetframe = (int)TargetFrame.Value;

            // Advance
            for (int i = 0; i < start_frame; i++)
            {
                sfmt.Next();
            }
            // Prepare
            ModelStatus status = new ModelStatus(Modelnum, sfmt)
            {
                raining = Raining.Checked
            };

            getsetting(sfmt);
            int totaltime = (int)TimeSpan.Value * 30;
            int frameinput1 = (int)Frame_min.Value;         // Input 1: Cast the rod
            int frameadvance, fishingdelay, frameinput2;    // Input 2: Pull the rod off water
            var fsetting   = getFishingSetting;
            int Timewindow = 2;

            // Start
            for (int i = 0; i <= totaltime; i++)
            {
                RNGPool.Save();

                // 2 Frames for delay calc
                // USUM v1.1 sub_39E2F0
                RNGPool.Rewind(0); RNGPool.CopyStatus(status);
                fishingdelay = (int)(RNGPool.getrand64 % 60) + fsetting.basedelay;
                if (Overview.Checked)
                {
                    RNGPool.Advance(1); // Keep timewindow at 2 to avoid calculation
                }
                else
                {
                    Timewindow = (int)(RNGPool.getrand64 % 15) + fsetting.platdelay + 14;
                }

                // Fishing Delay
                RNGPool.time_elapse7(fishingdelay);

                // Bitechance
                if (fsetting.suctioncups || (int)(RNGPool.getrand64 % 100) < 50)
                {
                    RNGPool.time_elapse7(1);
                    frameinput2 = RNGPool.index + frameinput1;
                    RNGPool.SaveStatus();

                    for (int j = 2; j <= Timewindow; j++)
                    {
                        RNGPool.LoadStatus();
                        RNGPool.time_elapse7(1);
                        frameinput2 += RNGPool.index;
                        RNGPool.SaveStatus();
                        RNGPool.DelayTime = fsetting.pkmdelay + Math.Max(0, fsetting.platdelay - j); //  Duplicates

                        var result = RNGPool.Generate7() as ResultW7;

                        if (!filter.CheckResult(result))
                        {
                            continue;
                        }
                        if (Overview.Checked)
                        {
                            result.RandNum = RNGPool.getsavepoint;
                        }
                        result.FrameDelayUsed += frameinput2 - frameinput1;
                        Frames.Add(new Frame(result, frame: frameinput2, time: (i + j + fishingdelay) * 2)
                        {
                            Frame0 = frameinput1
                        });
                    }
                }

                RNGPool.Load();

                if (Frames.Count > MAX_RESULTS_NUM)
                {
                    break;
                }

                // Move to next Frame, Update RNGPool
                frameadvance = status.NextState();
                frameinput1 += frameadvance;
                for (int j = 0; j < frameadvance; j++)
                {
                    RNGPool.AddNext(sfmt);
                }
            }
        }
Example #4
0
 private static void Advance(int n) => RNGPool.Advance(n);
Example #5
0
        private void Search6_Battle()
        {
            TinyMT tiny      = TTT.Checked ? new TinyMT(Program.mainform.TinySeeds) : new TinyMT(Seed.Value);
            int    frame     = (int)StartingFrame.Value;
            int    loopcount = (int)MaxResults.Value;
            int    delay     = (int)Delay.Value;
            ulong  N         = (ulong)Range.Value;

            CaptureResult.Details = CB_Detail.Checked || Filters.SelectedTab == TP_Misc;
            var capture6 = new Capture();

            if (Filters.SelectedTab == TP_Capture)
            {
                capture6.Gen6        = true;
                capture6.HPCurr      = (uint)HPCurr.Value;
                capture6.HPMax       = (uint)HPMax.Value;
                capture6.CatchRate   = (byte)CatchRate.Value;
                capture6.StatusBonus = (uint)(int)Status.SelectedValue;
                capture6.BallBonus   = (uint)(int)BallBonus.SelectedValue;
                capture6.DexBonus    = (uint)(int)DexBonus.SelectedValue;
                capture6.OPowerBonus = OPowerList[OPower.SelectedIndex];
                capture6.Calc();
                var criticalchance = capture6.CriticalRate / 256.0;
                var shakechance    = capture6.ShakeRate / 65536.0;
                var capturechance  = criticalchance * shakechance + (1 - criticalchance) * Math.Pow(shakechance, 4);
                L_output.Text = CB_Detail.Checked ? string.Format("Critical {0:P}  \tShake {1:P}", criticalchance, shakechance)
                    : string.Format("Critical {0:P}  \tSuccess {1:P}", criticalchance, capturechance);
            }

            for (int i = 0; i < frame; i++)
            {
                tiny.Next();
            }

            RNGPool.CreateBuffer(tiny);

            for (int i = 0; i < loopcount; i++, RNGPool.AddNext(tiny, AutoCheck: false))
            {
                var f = new Frame_Misc();
                f.Frame  = frame++;
                f.Rand32 = RNGPool.getcurrent;
                f.st     = RNGPool.getcurrentstate;

                RNGPool.Rewind(0);
                RNGPool.Advance(delay);
                if (filter.Random)
                {
                    f.RandN = (int)((RNGPool.getrand * N) >> 32);
                }
                if (ShowCapture)
                {
                    RNGPool.Rewind(0);
                    f.Crt = capture6.Catch();
                }

                if (!filter.check(f))
                {
                    continue;
                }

                Frames.Add(f);
            }
        }
Example #6
0
        private void Search7_Battle()
        {
            SFMT  sfmt      = new SFMT(Seed.Value);
            int   frame     = (int)StartingFrame.Value;
            int   loopcount = (int)MaxResults.Value;
            int   delay     = (int)Delay.Value;
            ulong N         = (ulong)Range.Value;

            CaptureResult.Details = SOSResult.Details = CB_Detail.Checked || Filters.SelectedTab == TP_Misc;
            var capture7 = new Capture();

            if (Filters.SelectedTab == TP_Capture)
            {
                capture7.HPCurr      = (uint)HPCurr.Value;
                capture7.HPMax       = (uint)HPMax.Value;
                capture7.CatchRate   = (byte)CatchRate.Value;
                capture7.StatusBonus = (uint)(int)Status.SelectedValue;
                capture7.BallBonus   = (uint)(int)BallBonus.SelectedValue;
                capture7.DexBonus    = (uint)(int)DexBonus.SelectedValue;
                capture7.OPowerBonus = RotoCatch.Checked ? 2.5f : 1.0f;
                capture7.Calc();
                var criticalchance = capture7.CriticalRate / 256.0;
                var shakechance    = capture7.ShakeRate / 65536.0;
                var capturechance  = criticalchance * shakechance + (1 - criticalchance) * Math.Pow(shakechance, 4);
                L_output.Text = CB_Detail.Checked ? string.Format("Critical {0:P}  \tShake {1:P}", criticalchance, shakechance)
                    : string.Format("Critical {0:P}  \tSuccess {1:P}", criticalchance, capturechance);
            }
            else if (SOS)
            {
                SOSRNG.ChainLength = (int)ChainLength.Value;
                SOSRNG.Weather     = L_Weather.Checked;

                int Rate1 = (int)CB_CallRate.SelectedValue * (int)HPBarColor.SelectedValue;
                if (AO.Checked)
                {
                    Rate1 *= 2;
                }
                if (Rate1 > 100)
                {
                    Rate1 = 100;
                }
                SOSRNG.Rate1 = (byte)Rate1;

                double Rate2 = (int)CB_CallRate.SelectedValue * (Intimidate.Checked ? 0x4CCC : 0x4000) / 4096.0;
                if (SameCaller.Checked)
                {
                    Rate2 *= 1.5;
                }
                if (SupperEffective.Checked)
                {
                    Rate2 *= 2;
                }
                if (LastCallFail.Checked)
                {
                    Rate2 *= 3;
                }
                if (Rate2 > 100)
                {
                    Rate2 = 100.0;
                }
                SOSRNG.Rate2 = (byte)Math.Round(Rate2);
            }

            for (int i = 0; i < frame; i++)
            {
                sfmt.Nextuint();
            }

            RNGPool.CreateBuffer(sfmt, AutoCheck: false); // Force 32bit

            for (int i = 0; i < loopcount; i++, RNGPool.AddNext(sfmt, AutoCheck: false))
            {
                var f = new Frame_Misc();
                f.Frame  = frame++;
                f.Rand32 = RNGPool.getcurrent;

                RNGPool.Rewind(0);
                RNGPool.Advance(delay);
                if (filter.Random)
                {
                    f.RandN = (int)(RNGPool.getrand % N);
                }
                if (ShowCapture)
                {
                    RNGPool.Rewind(0);
                    f.Crt = capture7.Catch();
                }
                if (ShowSOS)
                {
                    RNGPool.Rewind(0);
                    f.Srt = SOSRNG.Generate();
                }

                if (!filter.check(f))
                {
                    continue;
                }

                Frames.Add(f);
            }
        }
Example #7
0
 private static uint getrand => RNGPool.getrand; // MersenneTwister
 private static void Advance() => RNGPool.Advance(1);