public Results Run() { decimal firstCnt = 0; decimal secondCnt = 0; decimal bothHit = 0; for (int t = 0; t < NUMBER_TRIALS; t++) { // get roll results int roll1 = Utility.Global.MyRandom.Next(1, DICE_SIZE + 1); int roll2 = Utility.Global.MyRandom.Next(1, DICE_SIZE + 1); int roll3 = Utility.Global.MyRandom.Next(1, DICE_SIZE + 1); List<int> rolls = new List<int>(); rolls.Add(roll1); rolls.Add(roll2); rolls.Add(roll3); rolls.Sort(); int highRoll = rolls[2]; int secondRoll = rolls[1]; // create first possible result int highTotal = MyConfig.Strike1 + highRoll; int lowTotal = MyConfig.Strike2 + secondRoll; Results res1 = new Results(); if (highTotal >= MyConfig.Armor1) res1.HitFirst++; if (lowTotal >= MyConfig.Armor2) res1.HitSecond++; if (highTotal >= MyConfig.Armor1 && lowTotal >= MyConfig.Armor2) res1.HitBoth++; // create second possible result highTotal = MyConfig.Strike1 + secondRoll; lowTotal = MyConfig.Strike2 + highRoll; Results res2 = new Results(); if (highTotal >= MyConfig.Armor1) res2.HitFirst++; if (lowTotal >= MyConfig.Armor2) res2.HitSecond++; if (highTotal >= MyConfig.Armor1 && lowTotal >= MyConfig.Armor2) res2.HitBoth++; // pick the best result if (res1.Total() > res2.Total()) { if (res1.HitFirst == 1) firstCnt++; if (res1.HitSecond == 1) secondCnt++; if (res1.HitBoth == 1) bothHit++; } else { if (res2.HitFirst == 1) firstCnt++; if (res2.HitSecond == 1) secondCnt++; if (res2.HitBoth == 1) bothHit++; } } Results res = new Results(); res.HitFirst = Math.Round((decimal)firstCnt / NUMBER_TRIALS * 100, 2); res.HitSecond = Math.Round((decimal)secondCnt / NUMBER_TRIALS * 100, 2); res.HitBoth = Math.Round((decimal)bothHit / NUMBER_TRIALS * 100, 2); return res; }