Skip to content

Instantly share code, notes, and snippets.

@Lusamine
Last active June 12, 2022 11:50
Show Gist options
  • Save Lusamine/e6e36183f31cd771eb9ae24d27ab12a7 to your computer and use it in GitHub Desktop.
Save Lusamine/e6e36183f31cd771eb9ae24d27ab12a7 to your computer and use it in GitHub Desktop.
void Main()
{
// Initial state
ulong s0 = 0x0123456789ABCDEF;
ulong s1 = 0x0123456789ABCDEF;
// Set this for how far you want to search.
int maxAdvance = 1000;
var rng = new Xoroshiro128Plus(s0, s1);
for (int advances = 0; advances < maxAdvance; advances++)
{
GetStateCramomatic(advances, rng);
rng.Next();
}
}
// You can define other methods, fields, classes and namespaces here
private void GetStateCramomatic(int advance, Xoroshiro128Plus rng)
{
// itemRoll gives you 0-3. 0 is the 4th item you put in, 1 is the 3rd item, 2 is the 2nd item, 3 is the 1st item. That determines which apriball and shop ball if you're not using 4 identical apricorns.
// ballRoll gives you the regular ball or apriball, rolls 0-99. (0-24 = poke, 25-49 = great, 50-74 = shop ball 1, 75-98 = shop ball 2, 99 = apricorn ball)
// isSafariSport is True if you roll 1/1000 and land on 0. It overrides the ballRoll if you get it.
// isBonusCount is True if you roll 1/1000 on apri/sport/safari or 1/100 on regular shop balls and land on 0. You get 5 instead of 1.
var (s0, s1) = rng.GetState();
var output = $"{advance:000} | {s0:x16} | {s1:x16} |";
var itemRoll = rng.NextInt(4);
output = output + $" {itemRoll} |";
var ballRoll = rng.NextInt(100);
output = output + $" {ballRoll:00} |";
var isSafariSport = rng.NextInt(1000) == 0;
output = output + $" {isSafariSport} |";
var isBonusCount = false;
if (isSafariSport || ballRoll == 99)
isBonusCount = rng.NextInt(1000) == 0;
else
isBonusCount = rng.NextInt(100) == 0;
output = output + $" {isBonusCount}";
// Add your filters here.
// For Apricorn Ball only
//if (ballRoll != 99 || isSafariSport)
// return;
// For Safari/Sport Ball only
//if (!isSafariSport)
// return;
// For Apricorn or Safari/Sport Ball only
//if (ballRoll != 99 && !isSafariSport)
// return;
// For 5 balls only
//if (!isBonusCount)
// return;
Console.WriteLine(output);
}
@Lusamine
Copy link
Author

Setup is:

  1. Download/install LINQPad 7.
  2. Download dev build PKHeX.
  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 your params (ball targets).
  6. Click run.

RNG state is locked in right as you click on Cram-o-Matic and doesn't change in the ingredient menu.

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