Created
May 17, 2025 01:52
-
-
Save Lusamine/3f162101798dca855e6b97807c2ccf1d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| bool Sword = true; | |
| void Main() | |
| { | |
| // Initial state | |
| string ram = "D82C5B180FDEFE005E23F28A4FA36131"; | |
| string str0 = ram.Substring(16); | |
| string str1 = ram.Substring(0, 16); | |
| ulong s0 = Convert.ToUInt64(str0, 16); | |
| ulong s1 = Convert.ToUInt64(str1, 16); | |
| // Use this if you want to submit s0 and s1 instead | |
| //ulong s0 = 0x0123456789ABCDEF; | |
| //ulong s1 = 0x0123456789ABCDEF; | |
| // Set this for how far you want to search. | |
| ulong maxAdvance = 1000; | |
| Console.WriteLine("Adv | s0 | s1 | Rewards"); | |
| Console.WriteLine("-----+------------------+------------------+-------------------------------"); | |
| var table = Sword ? DiggingBroSkillSWRewards : DiggingBroSkillSHRewards; | |
| var rng = new Xoroshiro128Plus(s0, s1); | |
| for (ulong advances = 0; advances < maxAdvance; advances++) | |
| { | |
| GetStateDiggingBro(advances, table, rng); | |
| rng.Next(); | |
| } | |
| } | |
| Dictionary<string, uint> all_rewards = new(); | |
| // You can define other methods, fields, classes and namespaces here | |
| private void GetStateDiggingBro(ulong advance, RewardEntry[] table, Xoroshiro128Plus rng) | |
| { | |
| all_rewards.Clear(); | |
| var (s0, s1) = rng.GetState(); | |
| var output = $"{advance, 4} | {s0:x16} | {s1:x16} | "; | |
| HandleSafeRolls(ref rng, 1, table); | |
| while (true) | |
| { | |
| HandleRiskyRolls(table, ref rng); // Exits when we hit the danger zone. | |
| // Check for a second wind | |
| var roll = (uint)rng.NextInt(100); | |
| if (roll < 5) | |
| { | |
| HandleSafeRolls(ref rng, 1, table); // 1 safe roll and then back to risky ones | |
| } | |
| else | |
| { | |
| break; | |
| } | |
| } | |
| // Add your filters here. | |
| //if (!all_rewards.ContainsKey("Fossilized Dino")) | |
| // return; | |
| //if (all_rewards.Count < 5) | |
| // return; | |
| // Format rewards for printing. | |
| var sorted_rewards = from entry in all_rewards orderby entry.Key ascending select entry; | |
| var reward_string = string.Empty; | |
| foreach (KeyValuePair<string, uint> kvp in sorted_rewards) | |
| { | |
| if (reward_string.Length > 0) | |
| reward_string += ", "; | |
| reward_string += $"{kvp.Key} x{kvp.Value}"; | |
| } | |
| output += $"{reward_string}"; | |
| Console.WriteLine(output); | |
| } | |
| private void HandleSafeRolls(ref Xoroshiro128Plus rng, uint count, RewardEntry[] table) | |
| { | |
| for (var i = 0; i < count; i++) | |
| { | |
| var rand = (uint)rng.NextInt(10000); | |
| var reward = FindItemInTable(rand, table); | |
| if (reward == "Danger Zone") | |
| reward = "Rare Bone"; // Danger Zone gives Rare Bone during safe attempts. | |
| if (all_rewards.ContainsKey(reward)) | |
| all_rewards[reward]++; | |
| else | |
| all_rewards.Add(reward, 1); | |
| } | |
| } | |
| private void HandleRiskyRolls(RewardEntry[] table, ref Xoroshiro128Plus rng) | |
| { | |
| while (true) | |
| { | |
| var rand = (uint)rng.NextInt(10000); | |
| var reward = FindItemInTable(rand, table); | |
| if (reward == "Danger Zone") | |
| break; // Hit the danger zone. | |
| if (all_rewards.ContainsKey(reward)) | |
| all_rewards[reward]++; | |
| else | |
| all_rewards.Add(reward, 1); | |
| } | |
| } | |
| public class RewardEntry(uint min, uint max, string name) | |
| { | |
| public uint Min = min; | |
| public uint Max = max; | |
| public string Item = name; | |
| } | |
| public static string FindItemInTable(uint rand, RewardEntry[] table) | |
| { | |
| foreach (RewardEntry entry in table) | |
| { | |
| if (rand >= entry.Min && rand <= entry.Max) | |
| return entry.Item; | |
| } | |
| return ""; | |
| } | |
| public static readonly RewardEntry[] DiggingBroSkillSWRewards = | |
| [ | |
| new(6000, 9999, "Danger Zone"), | |
| new(5999, 5999, "Gold Bottle Cap"), | |
| new(5850, 5998, "Bottle Cap"), | |
| new(5650, 5849, "Normal Gem"), | |
| new(5450, 5649, "Sticky Barb"), | |
| new(5250, 5449, "Light Clay"), | |
| new(4950, 5249, "Lagging Tail"), | |
| new(4650, 4949, "Iron Ball"), | |
| new(4350, 4649, "Metal Coat"), | |
| new(4050, 4349, "Ice Stone"), | |
| new(3750, 4049, "Dawn Stone"), | |
| new(3450, 3749, "Dusk Stone"), | |
| new(3150, 3449, "Shiny Stone"), | |
| new(2850, 3149, "Moon Stone"), | |
| new(2550, 2849, "Sun Stone"), | |
| new(2450, 2549, "Fossilized Fish"), // Difference between versions is in the fossil rates. | |
| new(2350, 2449, "Fossilized Drake"), | |
| new(1850, 2349, "Fossilized Dino"), | |
| new(1350, 1849, "Fossilized Bird"), | |
| new(1050, 1349, "Wishing Piece"), | |
| new( 550, 1049, "Comet Shard"), | |
| new( 0, 549, "Rare Bone") | |
| ]; | |
| public static readonly RewardEntry[] DiggingBroSkillSHRewards = | |
| [ | |
| new(6000, 9999, "Danger Zone"), | |
| new(5999, 5999, "Gold Bottle Cap"), | |
| new(5850, 5998, "Bottle Cap"), | |
| new(5650, 5849, "Normal Gem"), | |
| new(5450, 5649, "Sticky Barb"), | |
| new(5250, 5449, "Light Clay"), | |
| new(4950, 5249, "Lagging Tail"), | |
| new(4650, 4949, "Iron Ball"), | |
| new(4350, 4649, "Metal Coat"), | |
| new(4050, 4349, "Ice Stone"), | |
| new(3750, 4049, "Dawn Stone"), | |
| new(3450, 3749, "Dusk Stone"), | |
| new(3150, 3449, "Shiny Stone"), | |
| new(2850, 3149, "Moon Stone"), | |
| new(2550, 2849, "Sun Stone"), | |
| new(2050, 2549, "Fossilized Fish"), // Difference between versions is in the fossil rates. | |
| new(1550, 2049, "Fossilized Drake"), | |
| new(1450, 1549, "Fossilized Dino"), | |
| new(1350, 1449, "Fossilized Bird"), | |
| new(1050, 1349, "Wishing Piece"), | |
| new( 550, 1049, "Comet Shard"), | |
| new( 0, 549, "Rare Bone") | |
| ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment