Skip to content

Instantly share code, notes, and snippets.

@Lusamine
Last active June 1, 2025 15:23
Show Gist options
  • Select an option

  • Save Lusamine/4b5bcf22acf931ffd824433ae688fa21 to your computer and use it in GitHub Desktop.

Select an option

Save Lusamine/4b5bcf22acf931ffd824433ae688fa21 to your computer and use it in GitHub Desktop.
// Unfortunately this area is very noisy and everything is blinking while you try to pick up eggs.
// You can set this to a certain value if you tend to see that many blinks from menu to egg generation...
// Just adjust it up until what you hit is on Adv 0.
const uint blinks = 0;
// You probably have either Shiny Charm or Masuda Method, else you'd get PID rolls.
bool shiny_charm_or_masuda_method = true;
void Main()
{
// Initial state if you want to use 64-bit.
// s0 should be s1, s0 from CS
// s1 should be s3, s2 from CS
ulong s0 = 0x0123456789ABCDEF;
ulong s1 = 0x0123456789ABCDEF;
// Initial state if you want to use 128-bit.
/*
string ram = "0123456789ABCDEF0123456789ABCDEF";
string str0 = ram.Substring(16);
string str1 = ram.Substring(0, 16);
ulong s0 = Convert.ToUInt64(str0, 16);
ulong s1 = Convert.ToUInt64(str1, 16);
*/
// Set this for how far you want to search.
int maxAdvance = 10000;
Console.WriteLine("Adv | s0 | s1 | Height | Weight");
Console.WriteLine("-----+------------------+------------------+--------+---------");
var rng = new XorShift128(s0, s1);
for (int advances = 0; advances < maxAdvance; advances++)
{
GetStateEggSize(advances, rng);
rng.Next();
}
Console.WriteLine("Search completed.");
}
private void GetStateEggSize(int advance, XorShift128 rng)
{
var (s0, s1) = rng.GetState64();
var output = $"{advance, 4} | {s0:x16} | {s1:x16} |";
// Blinks
for (var i = 0; i < blinks; i++)
rng.NextUInt(16);
// PID roll only if you don't have either, but then why are you doing this?
if (!shiny_charm_or_masuda_method)
rng.NextUInt();
var height = (int)rng.NextUInt(0x81) + (int)rng.NextUInt(0x80);
var weight = (int)rng.NextUInt(0x81) + (int)rng.NextUInt(0x80);
output = output + $" {height, -6} | {weight, -6}";
// Add your filters here.
//if (height != 255 && height != 0)
// return;
Console.WriteLine(output);
}
@Lusamine
Copy link
Copy Markdown
Author

This script is used to predict Egg sizes after picking them up in BDSP. You'll need to click "Yes" and wait on the menu for "You received the Egg from the Pokémon Nursery Man."

Setup is:

  1. Download/install LINQPad (latest version is fine).
  2. Download dev build PKHeX from https://projectpokemon.org/home/files/file/2445-pkhex-development-build/
  3. Press F4 in LINQPad and add PKHeX.Core.dll to first tab, and PKHeX.Core to second tab,
  4. Change the language at the top to C# program, then copy/paste the script in verbatim.
  5. Edit the filter for your desired Height.
  6. Click run.

Recommended LINQPad settings so output is monospaced:

  1. Edit > Preferences > Results
  2. Click "Launch Editor" under Style Sheet for text (HTML) results.
  3. Paste this snippet and "Apply Changes".
    body
    {
    	margin: 0.3em 0.3em 0.4em 0.4em;
    	font-family: Consolas;
    }
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment