Last active
January 14, 2022 05:36
-
-
Save Lusamine/cc23ef1b808b61b3c05c95d06654eb68 to your computer and use it in GitHub Desktop.
Ignored nature because lazy and spreads are limited already; you can use Synchronize if you care.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
// Initial state | |
// s0 should be s1, s0 from CS | |
// s1 should be s3, s2 from CS | |
ulong s0 = 0x0123456789ABCDEF; | |
ulong s1 = 0x0123456789ABCDEF; | |
// Set this for how far you want to search. | |
int maxAdvance = 500000; | |
var rng = new XorShift128(s0, s1); | |
for (int advances = 0; advances < maxAdvance; advances++) | |
{ | |
GetStateRoamer(advances, rng); | |
rng.Next(); | |
} | |
} | |
// You can define other methods, fields, classes and namespaces here | |
private void GetStateRoamer(int advance, XorShift128 rng) | |
{ | |
int FlawlessIVs = 3; | |
var (s0, s1) = rng.GetState64(); | |
var output = $"{advance} | {s0:x16} | {s1:x16} |"; | |
var seed = rng.NextUInt(); // Seed is also the EC. | |
output = output + $" {seed:x8} |"; | |
var xoro = new Xoroshiro128Plus8b(seed); // Feed the seed into a xoroshiro object. | |
var fakeTid = xoro.NextUInt(); | |
var pid = xoro.NextUInt(); | |
output = output + $" {pid:x8}"; | |
bool isShiny = false; | |
uint shinyXor = 0; | |
int TSV = (int)((fakeTid >> 16 ^ (fakeTid & 0xFFFF)) >> 4); | |
int PSV = (int)((pid >> 16 ^ (pid & 0xFFFF)) >> 4); | |
if (PSV == TSV) // Shiny check vs a fake trainer. | |
{ | |
var upper = (pid >> 16) ^ (fakeTid >> 16); | |
shinyXor = (pid & 0xFFFF) ^ (fakeTid & 0xFFFF) ^ upper; | |
isShiny = true; | |
var shinySymbol = shinyXor == 0 ? "Q" : "T"; | |
output = output + $" {shinySymbol} |"; | |
} | |
else | |
output = output + " |"; | |
int[] ivs = {-1, -1, -1, -1, -1, -1}; | |
var i = 0; | |
while (i < FlawlessIVs) | |
{ | |
var next = xoro.NextUInt(6); | |
if (ivs[next] == -1) | |
{ | |
ivs[next] = 31; | |
i++; | |
} | |
} | |
var ivstring = ""; | |
for (i = 0; i < 6; i++) | |
{ | |
if (ivs[i] == -1) | |
{ | |
var next = xoro.NextUInt(32); | |
ivs[i] = (int)next; | |
} | |
ivstring += ivs[i]; | |
if (i < 5) | |
ivstring += "/"; | |
} | |
output = output + $" {ivstring}"; | |
// Add your filters here. | |
if (!isShiny) | |
return; | |
if (shinyXor != 0) | |
return; | |
//if (ivs[0] != 31 || ivs[1] != 0 || ivs[2] != 31 || ivs[3] != 31 || ivs[4] != 31 || ivs[5] != 31) | |
// return; | |
Console.WriteLine(output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup is:
PKHeX.Core
to second tab,