Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is C# script to find out how many 4* you'll get in X amount of pulls
- // You can run this with online C# compiler like https://www.programiz.com/csharp-programming/online-compiler/
- // Just simply copy and paste this entire document to the website
- using System;
- using System.Collections.Generic;
- public class GachaPitySimulation
- {
- // Configurable variables
- static int pullsPerPlayer = 75;
- static int simulationCount = 10000000;
- const double purpleRate = 0.06;
- const int pityBlock = 10;
- public static void Main()
- {
- Random rng = new Random();
- Dictionary<int, long> distribution = new Dictionary<int, long>();
- long totalPurple = 0;
- for (int sim = 0; sim < simulationCount; sim++)
- {
- int purpleCount = SimulatePlayer(rng);
- totalPurple += purpleCount;
- if (!distribution.ContainsKey(purpleCount))
- distribution[purpleCount] = 0;
- distribution[purpleCount]++;
- }
- double averagePurple = (double)totalPurple / simulationCount;
- Console.WriteLine($"Simulation Count: {simulationCount}");
- Console.WriteLine($"Pulls per Player: {pullsPerPlayer}");
- Console.WriteLine($"Average Purple per Player: {averagePurple}");
- Console.WriteLine($"Total Purple Obtained: {totalPurple}");
- Console.WriteLine("\nDistribution (Purples : Players):");
- foreach (var kv in distribution)
- {
- Console.WriteLine($"{kv.Key},{kv.Value}");
- }
- }
- static int SimulatePlayer(Random rng)
- {
- int purpleCount = 0;
- int pullIndex = 0;
- while (pullIndex < pullsPerPlayer)
- {
- int pullsInBlock = Math.Min(pityBlock, pullsPerPlayer - pullIndex);
- int blockPurple = 0;
- for (int i = 0; i < pullsInBlock; i++)
- {
- if (rng.NextDouble() < purpleRate)
- blockPurple++;
- }
- // Apply pity guarantee
- if (blockPurple == 0)
- blockPurple = 1;
- purpleCount += blockPurple;
- pullIndex += pullsInBlock;
- }
- return purpleCount;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment