ReForgeMode

GFL 2 4* Gacha Simulation

Mar 7th, 2026 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.24 KB | None | 0 0
  1. // This is C# script to find out how many 4* you'll get in X amount of pulls
  2. // You can run this with online C# compiler like https://www.programiz.com/csharp-programming/online-compiler/
  3. // Just simply copy and paste this entire document to the website
  4.  
  5. using System;
  6. using System.Collections.Generic;
  7.  
  8. public class GachaPitySimulation
  9. {
  10.     // Configurable variables
  11.     static int pullsPerPlayer = 75;
  12.     static int simulationCount = 10000000;
  13.  
  14.     const double purpleRate = 0.06;
  15.     const int pityBlock = 10;
  16.  
  17.     public static void Main()
  18.     {
  19.         Random rng = new Random();
  20.  
  21.         Dictionary<int, long> distribution = new Dictionary<int, long>();
  22.  
  23.         long totalPurple = 0;
  24.  
  25.         for (int sim = 0; sim < simulationCount; sim++)
  26.         {
  27.             int purpleCount = SimulatePlayer(rng);
  28.  
  29.             totalPurple += purpleCount;
  30.  
  31.             if (!distribution.ContainsKey(purpleCount))
  32.                 distribution[purpleCount] = 0;
  33.  
  34.             distribution[purpleCount]++;
  35.         }
  36.  
  37.         double averagePurple = (double)totalPurple / simulationCount;
  38.  
  39.         Console.WriteLine($"Simulation Count: {simulationCount}");
  40.         Console.WriteLine($"Pulls per Player: {pullsPerPlayer}");
  41.         Console.WriteLine($"Average Purple per Player: {averagePurple}");
  42.         Console.WriteLine($"Total Purple Obtained: {totalPurple}");
  43.  
  44.         Console.WriteLine("\nDistribution (Purples : Players):");
  45.  
  46.         foreach (var kv in distribution)
  47.         {
  48.             Console.WriteLine($"{kv.Key},{kv.Value}");
  49.         }
  50.     }
  51.  
  52.     static int SimulatePlayer(Random rng)
  53.     {
  54.         int purpleCount = 0;
  55.  
  56.         int pullIndex = 0;
  57.  
  58.         while (pullIndex < pullsPerPlayer)
  59.         {
  60.             int pullsInBlock = Math.Min(pityBlock, pullsPerPlayer - pullIndex);
  61.  
  62.             int blockPurple = 0;
  63.  
  64.             for (int i = 0; i < pullsInBlock; i++)
  65.             {
  66.                 if (rng.NextDouble() < purpleRate)
  67.                     blockPurple++;
  68.             }
  69.  
  70.             // Apply pity guarantee
  71.             if (blockPurple == 0)
  72.                 blockPurple = 1;
  73.  
  74.             purpleCount += blockPurple;
  75.  
  76.             pullIndex += pullsInBlock;
  77.         }
  78.  
  79.         return purpleCount;
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment