public static void ContestRollsAction() { Random generator = new Random(); int[] batches = new int[20]; for (int i = 0; i < batches.Length; i++) { if (i == batches.Length - 1 && numRollsPerThread % 20 != 0) { batches[i] = numRollsPerThread % 20; } else { batches[i] = numRollsPerThread / 20; } } // Split into batches (5% in each) // Do 1 batch at a time, update Dictionary <Krank.Result, int> results = new Dictionary <Krank.Result, int>(); results.Add(Krank.Result.win, 0); results.Add(Krank.Result.lose, 0); results.Add(Krank.Result.draw, 0); results.Add(Krank.Result.nowin, 0); for (int i = 0; i < batches.Length; i++) { Console.WriteLine($"Thread #{Thread.CurrentThread.Name} batch [{i+1}/{batches.Length}]"); int batchSize = batches[i]; Dictionary <Krank.Result, int> batchResults = Krank.ManyContests(batchSize, numDice, numDiceB, generator); foreach (Krank.Result key in batchResults.Keys) { results[key] += batchResults[key]; } } Console.WriteLine($"Thread #{Thread.CurrentThread.Name} DONE"); threadedContestResults.TryAdd(Thread.CurrentThread.Name, results); }
static void StraightRollsAction() { int r = Krank.ManyDieRoll(numRollsPerThread, numDice, new Random()); threadedResults.TryAdd(Thread.CurrentThread.Name, r); }