public void AddWeightByReachEnd(int aDiceHistoryLengthWithDiceNumber) { Weight = 0; foreach (var dh in DicesHistories) { int missingDices = aDiceHistoryLengthWithDiceNumber - dh.Length; int dhWeight = 1; while (missingDices > m_Rank.Length) { dhWeight *= (int)Math.Pow(GameRules.DICE_NB_FACES, m_Rank.Length) * MathFunc.Factorial(m_Rank.Length); missingDices -= m_Rank.Length; } dhWeight *= (int)Math.Pow(GameRules.DICE_NB_FACES, missingDices) * MathFunc.Factorial(missingDices); Weight += dhWeight; } }