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 GFL2GachaSimulation
- {
- static int PLAYER_COUNT = 10_000_000;
- static int MAX_PULL_TRACK = 160;
- static double BASE_FIVE_STAR_RATE = 0.006; // 0.6%
- static int SOFT_PITY_START = 58;
- static int HARD_PITY = 90;
- static double FEATURED_RATE = 0.5; // 50-50
- static Random rng = new Random();
- static int[] winTally = new int[MAX_PULL_TRACK + 1];
- static void Main()
- {
- long totalPulls = 0;
- for (int player = 0; player < PLAYER_COUNT; player++)
- {
- int pullsUsed = SimulatePlayer();
- if (pullsUsed <= MAX_PULL_TRACK)
- winTally[pullsUsed]++;
- totalPulls += pullsUsed;
- }
- PrintResults(totalPulls);
- }
- private static int SimulatePlayer()
- {
- int pulls = 0;
- int pityCounter = 0;
- bool guaranteedFeatured = false;
- while (true)
- {
- pulls++;
- pityCounter++;
- double fiveStarChance = CalculateFiveStarChance(pityCounter);
- if (rng.NextDouble() < fiveStarChance)
- {
- pityCounter = 0;
- bool isFeatured;
- if (guaranteedFeatured)
- {
- isFeatured = true;
- guaranteedFeatured = false;
- }
- else
- {
- isFeatured = rng.NextDouble() < FEATURED_RATE;
- if (!isFeatured)
- guaranteedFeatured = true;
- }
- if (isFeatured)
- return pulls;
- }
- }
- }
- private static double CalculateFiveStarChance(int pity)
- {
- if (pity < SOFT_PITY_START)
- return BASE_FIVE_STAR_RATE;
- if (pity >= HARD_PITY)
- return 1.0;
- int softCount = HARD_PITY - SOFT_PITY_START;
- double increasePerPull = (1.0 - BASE_FIVE_STAR_RATE) / softCount;
- int softSteps = pity - SOFT_PITY_START + 1;
- return BASE_FIVE_STAR_RATE + increasePerPull * softSteps;
- }
- private static void PrintResults(long totalPulls)
- {
- Console.WriteLine("Pull\tCount\t\tPercentage");
- for (int i = 1; i <= MAX_PULL_TRACK; i++)
- {
- int count = winTally[i];
- double percent = (double)count / PLAYER_COUNT * 100;
- Console.WriteLine($"{i}\t{count}\t\t{percent:F4}%");
- }
- double average = (double)totalPulls / PLAYER_COUNT;
- Console.WriteLine();
- Console.WriteLine($"Average Pulls: {average:F2}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment