using System.Diagnostics;
using System.Threading.Tasks;
const int _OddsFeatured = 3;
static PullResult Pull(Random rng)
var result = rng.Next(0, 1000);
return result >= _Odds5 ? PullResult.Miss : result >= _OddsFeatured ? PullResult.OffBanner5 : PullResult.Featured5;
static PullResult PullWithPity(Random rng, int pullCount)
if (pullCount % 90 == 0 )
return rng.Next(0, 2) > 0 ? PullResult.OffBanner5 : PullResult.Featured5;
static int PullsTillFeatured(Random rng)
PullResult result = PullResult.Miss;
while (result != PullResult.Featured5)
result = PullWithPity(rng, pullsSinceLast5);
if ( result == PullResult.OffBanner5)
result = PullResult.Featured5;
static Int64 SimPullsTillFeatured5(int totalSims)
Random rng = new Random();
for (simCount = 0; simCount < totalSims; ++simCount)
pullsPerSim += PullsTillFeatured(rng);
static void Main(string[] args)
Stopwatch stopWatch = new Stopwatch();
const int oneHundredThousand = 100000;
const int oneMillion = oneHundredThousand * 10;
const int oneHundredMillion = oneMillion * 100;
const int oneBillion = oneHundredMillion * 10;
const int targetSims = oneMillion;
const int simsPerRun = oneHundredThousand;
const int workSplit = targetSims/ simsPerRun;
Parallel.For(0, workSplit,
var simResult = SimPullsTillFeatured5(simsPerRun);
Interlocked.Add(ref totalSimsRun, simsPerRun);
Interlocked.Add(ref totalPulls, simResult);
System.Console.WriteLine($"loop = {index}, sim={simResult}, total={totalPulls}");
double ave = (double)totalPulls / totalSimsRun;
System.Console.WriteLine($"\n\tAverage pulls till Featured Character := {ave}\n");
TimeSpan ts = stopWatch.Elapsed;
Console.WriteLine($"Seconds to complete {ts.TotalSeconds}");