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); } }
private static int GetFramesForward(ulong s0, ulong s1, ulong n0, ulong n1, int loop) { var rand = new Xoroshiro128Plus(s0, s1); for (int i = 0; i < loop; i++) { _ = rand.Next(); if (rand.GetState() == (n0, n1)) { return(i); } } return(-1); }
public static bool IsOriginalSeed(this Spawner8a spawner, ulong groupSeed) { var rand = new Xoroshiro128Plus(groupSeed); for (int i = 0; i < Spawner8a.EntryCount; i++) { var entry = spawner[i]; if (entry.IsEmpty != 0) { break; } if (entry.GenerateSeed != rand.Next()) { return(false); } if (entry.AlphaSeed != rand.Next()) { return(false); } } return(rand.Next() == spawner.Meta.GroupSeed); }
public static int GetNextShinyFrame(ulong seed, out uint type, out int star, out int square) { star = -1; square = -1; 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); type = GetShinyType(PID, SIDTID); if (star == -1) { if (type == 1) { star = i; } } if (square == -1) { if (type == 2) { square = i; } } // Get the next seed, and reset for the next iteration rng = new Xoroshiro128Plus(seed); seed = rng.Next(); rng = new Xoroshiro128Plus(seed); if (i > 100_000) { return(star & square); } else if (star != -1 && square != -1) { return(star & square); } } }
public static int GetNextShinyFrame(ulong seed, out uint type) { 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); type = GetShinyType(PID, SIDTID); if (type != 0) { return(i); } // Get the next seed, and reset for the next iteration rng = new Xoroshiro128Plus(seed); seed = rng.Next(); rng = new Xoroshiro128Plus(seed); } }
public static void SpecificSeedSearch(DenUtil.RaidData raidInfo, out long frames, out ulong seedRes, out ulong threeDay, out string ivSpread) { threeDay = seedRes = 0; frames = 0; ivSpread = string.Empty; ulong seed = raidInfo.Den.Seed; var rng = new Xoroshiro128Plus(seed); for (long i = 0; i < raidInfo.SearchRange; i++) { if (i > 0) { rng = new Xoroshiro128Plus(seed); seed = rng.Next(); rng = new Xoroshiro128Plus(seed); } uint EC = (uint)rng.NextInt(0xFFFFFFFF); uint SIDTID = (uint)rng.NextInt(0xFFFFFFFF); uint PID = (uint)rng.NextInt(0xFFFFFFFF); uint shinytype = GetShinyType(PID, SIDTID); if (shinytype == (uint)raidInfo.Shiny) { rng = GetIVs(rng, raidInfo.IVs, raidInfo.GuaranteedIVs, out uint[,] allIVs, out bool IVMatch); if (!IVMatch) { continue; } GetCharacteristic(EC, allIVs, raidInfo.GuaranteedIVs - 1, out bool charMatch, raidInfo.Characteristic); if (!charMatch) { continue; } rng = GetAbility(rng, raidInfo.Den.IsEvent ? raidInfo.RaidDistributionEncounter.Ability : (uint)raidInfo.RaidEncounter.Ability, out uint abilityT); bool abilityMatch = raidInfo.Ability == AbilityType.Any ? abilityT != (uint)raidInfo.Ability : abilityT == (uint)raidInfo.Ability; if (!abilityMatch) { continue; } rng = GetGender(rng, raidInfo.Ratio, raidInfo.Den.IsEvent ? raidInfo.RaidDistributionEncounter.Gender : (uint)raidInfo.RaidEncounter.Gender, out uint genderT); bool genderMatch = raidInfo.Gender == GenderType.Any ? genderT != (uint)raidInfo.Gender : genderT == (uint)raidInfo.Gender; if (!genderMatch) { continue; } GetNature(rng, raidInfo.Den.IsEvent ? raidInfo.RaidDistributionEncounter.Species : raidInfo.RaidEncounter.Species, raidInfo.Den.IsEvent ? raidInfo.RaidDistributionEncounter.AltForm : raidInfo.RaidEncounter.AltForm, out uint natureT); bool natureMatch = raidInfo.Nature == Nature.Random ? natureT != (uint)raidInfo.Nature : natureT == (uint)raidInfo.Nature; if (!natureMatch) { continue; } ivSpread = DenUtil.IVSpreadByStar(GetIVSpread(allIVs), raidInfo, seed); frames = i; seedRes = seed; for (int d = 3; d > 0; d--) { seed -= 0x82A2B175229D6A5B; } threeDay = seed; return; } if (i >= raidInfo.SearchRange) { return; } } }