static BetrayalMath() { DiceStats = new DiceRollStats[NumDice + 1]; DiceStats[0] = new DiceRollStats(0, 0, 0, new int[] { 1 }, new double[] { 1 }); int prevCount = 0; for (int d = 1; d < NumDice + 1; ++d) { int max = 2 * d; int[] chances = new int[max]; int[] numOutcomes = new int[max]; int count = ZachMath.IntPow(3, d); for (int i = 0; i < d; ++i) { var prevDiceStats = DiceStats[d]; for (int n = 0; n < prevDiceStats.MaxRoll; ++n) { int num = prevDiceStats.NumOutcomes[n]; for (int j1 = 0; j1 <= 2; ++j1) { for (int j2 = j1; j2 <= 2; ++j2) { numOutcomes[n + j2] += j1; } } } } } }
public KeyValuePair <int, int> ToIDs(int[] answerIndices) { int answersID = 0; foreach (var answer in answerIndices) { answersID += ZachMath.IntPow(2, answer + 1); } return(new KeyValuePair <int, int>(id, answersID)); }
public DormActivities(DormInfo dorm) { AvailableActivities = ActivityNames.Concat( dorm.AllowedSpecial.ToString().Split( new string[] { " & " }, StringSplitOptions.None ) ).ToArray(); PartnerPriorities = new Dictionary <Dorm, int>(); Dorm = dorm.Dorm; // The start of binary is 2^0, so everything is offset incorrectly by default int dormNum = Convert.ToInt32(Char.GetNumericValue(Dorm.ToString()[1])) - 1; int dormNumStart = Math.Max(0, dormNum - 1); int min = ZachMath.IntPow(2, dormNumStart); int boysMax = ZachMath.IntPow(2, Math.Min(5, dormNum + 1)); int girlsMax = ZachMath.IntPow(2, Math.Min(6, dormNum + 1)) * 64; int boysMin = min; int girlsMin = min * 64; int boysOffset = 0; int boysConstant = 0; int girlsOffset = 0; int girlsConstant = 0; if (dorm.IsGirl) { girlsOffset = 1; girlsConstant = 4; boysOffset = 2; boysConstant = 5; } else { girlsOffset = 2; girlsConstant = 5; boysOffset = 1; boysConstant = 4; } int countingDormNum = dormNumStart; for (int i = boysMin; i <= boysMax; i *= 2) { PartnerPriorities.Add((Dorm)i, boysConstant - Math.Abs(dormNum - countingDormNum) * boysOffset); ++countingDormNum; } countingDormNum = dormNumStart; for (int i = girlsMin; i <= girlsMax; i *= 2) { PartnerPriorities.Add((Dorm)i, girlsConstant - Math.Abs(dormNum - countingDormNum) * girlsOffset); ++countingDormNum; } if (dormNum >= 4) { PartnerPriorities.Add(Dorm._1B, 1); PartnerPriorities.Add(Dorm._1G, 1); } else if (dormNum == 0) { PartnerPriorities.Add(Dorm._5B, 1); PartnerPriorities.Add(Dorm._5G, 1); PartnerPriorities.Add(Dorm._6B, 1); PartnerPriorities.Add(Dorm._6G, 1); PartnerPriorities.Add(Dorm._7G, 1); } PartnerPriorities.Remove(this.Dorm); }