ReForgeMode

GFL2 Gacha Simulation

Mar 9th, 2026
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.96 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 GFL2GachaSimulation
  9. {
  10.     static int PLAYER_COUNT = 10_000_000;
  11.     static int MAX_PULL_TRACK = 160;
  12.  
  13.     static double BASE_FIVE_STAR_RATE = 0.006; // 0.6%
  14.  
  15.     static int SOFT_PITY_START = 58;
  16.     static int HARD_PITY = 90;
  17.  
  18.     static double FEATURED_RATE = 0.5; // 50-50
  19.  
  20.  
  21.  
  22.     static Random rng = new Random();
  23.  
  24.     static int[] winTally = new int[MAX_PULL_TRACK + 1];
  25.  
  26.     static void Main()
  27.     {
  28.         long totalPulls = 0;
  29.  
  30.         for (int player = 0; player < PLAYER_COUNT; player++)
  31.         {
  32.             int pullsUsed = SimulatePlayer();
  33.  
  34.             if (pullsUsed <= MAX_PULL_TRACK)
  35.                 winTally[pullsUsed]++;
  36.  
  37.             totalPulls += pullsUsed;
  38.         }
  39.  
  40.         PrintResults(totalPulls);
  41.     }
  42.  
  43.  
  44.     private static int SimulatePlayer()
  45.     {
  46.         int pulls = 0;
  47.  
  48.         int pityCounter = 0;
  49.         bool guaranteedFeatured = false;
  50.  
  51.         while (true)
  52.         {
  53.             pulls++;
  54.             pityCounter++;
  55.  
  56.             double fiveStarChance = CalculateFiveStarChance(pityCounter);
  57.  
  58.             if (rng.NextDouble() < fiveStarChance)
  59.             {
  60.                 pityCounter = 0;
  61.  
  62.                 bool isFeatured;
  63.  
  64.                 if (guaranteedFeatured)
  65.                 {
  66.                     isFeatured = true;
  67.                     guaranteedFeatured = false;
  68.                 }
  69.                 else
  70.                 {
  71.                     isFeatured = rng.NextDouble() < FEATURED_RATE;
  72.  
  73.                     if (!isFeatured)
  74.                         guaranteedFeatured = true;
  75.                 }
  76.  
  77.                 if (isFeatured)
  78.                     return pulls;
  79.             }
  80.         }
  81.     }
  82.  
  83.  
  84.     private static double CalculateFiveStarChance(int pity)
  85.     {
  86.         if (pity < SOFT_PITY_START)
  87.             return BASE_FIVE_STAR_RATE;
  88.  
  89.         if (pity >= HARD_PITY)
  90.             return 1.0;
  91.  
  92.         int softCount = HARD_PITY - SOFT_PITY_START;
  93.  
  94.         double increasePerPull = (1.0 - BASE_FIVE_STAR_RATE) / softCount;
  95.  
  96.         int softSteps = pity - SOFT_PITY_START + 1;
  97.  
  98.         return BASE_FIVE_STAR_RATE + increasePerPull * softSteps;
  99.     }
  100.  
  101.  
  102.     private static void PrintResults(long totalPulls)
  103.     {
  104.         Console.WriteLine("Pull\tCount\t\tPercentage");
  105.  
  106.         for (int i = 1; i <= MAX_PULL_TRACK; i++)
  107.         {
  108.             int count = winTally[i];
  109.  
  110.             double percent = (double)count / PLAYER_COUNT * 100;
  111.  
  112.             Console.WriteLine($"{i}\t{count}\t\t{percent:F4}%");
  113.         }
  114.  
  115.         double average = (double)totalPulls / PLAYER_COUNT;
  116.  
  117.         Console.WriteLine();
  118.         Console.WriteLine($"Average Pulls: {average:F2}");
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment