public RatingInfoDoubles.WeightingFactors CalculateMatchWeight(TeamInfo playerTeam, TeamInfo opponentTeam, Result r, int numPartnerResults)
        {
            /*
             * Match Weight is A x B x C x D * E * F
             * Where:
             * A = Opponent's Player Rating Reliability
             * B = Parter Frequency
             * C = Match Competitiveness Factor
             * D = Opponent Benchmark Reliability Factor
             * E = Interpool Reliability Factor
             * F = Team Rating Reliability
             */

            var a = (_ratingRule.EnableMatchFormatReliability) ? CalculateMatchFormatReliabilityFactor(r) : 10.0f;
            var b = _ratingRule.EnablePartnerFrequencyReliability ? CalculatePartnerFrequency(numPartnerResults) : 1.0f;

            var c           = (_ratingRule.EnableMatchCompetitivenessCoeffecient) ? MatchCompetivenessCalculator.CalculateMatchCompetivenessCoeffecient(playerTeam, opponentTeam, r, _ratingRule) : 1.0f;
            var d           = 1.0f; // not yet used
            var e           = (_ratingRule.EnableInterpoolCoeffecient) ? CalculateInterpoolCoefficient(playerTeam, opponentTeam) : 1.0f;
            var f           = CalculateOpponentRatingReliabilityFactor(opponentTeam);
            var matchWeight = a * b * c * d * e * f;

            return(new RatingInfoDoubles.WeightingFactors
            {
                MatchFormatReliability = a,
                MatchFrequencyReliability = b,
                MatchCompetitivenessCoeffecient = c,
                BenchmarkMatchCoeffecient = d,
                OpponentRatingReliability = f,
                InterpoolCoeffecient = e,
                MatchWeight = Math.Truncate(100000 * matchWeight) / 100000
            });
        }
        public RatingInfo.WeightingFactors CalculateMatchResultRelibilityFactor(Player player, Result r, Player opponent, float opponentFrequency, bool againstBenchmark, RatingRule rule)
        {
            /*
             * Match Result Reliabiliy Factor is A x B x C x D
             * Where:
             * A = Opponent's Player Rating Reliability
             * B = Match Format Reliability
             * C = Match Frequency Reliability
             * D = Match Competitiveness Coeffecient
             * E = Benchmark Match Coeffecient
             * F = Interpool Match Coeffecient
             */

            float a, b, c, d, rr, f;
            bool  collegeInterpoolApplied = false;

            a  = (rule.EnableOpponentRatingReliability) ? CalculateOpponentRatingReliability(opponent) : 10.0f;
            b  = (rule.EnableMatchFormatReliability) ? CalculateMatchFormatReliability(r, rule) : 1.0f;
            c  = (rule.EnableMatchFrequencyReliability) ? 2 / (opponentFrequency + 1) : 1.0f;
            d  = (rule.EnableMatchCompetitivenessCoeffecient) ? MatchCompetivenessCalculator.CalculateMatchCompetivenessCoeffecient(player, opponent, r, rule) : 1.0f;
            f  = (rule.EnableInterpoolCoeffecient) ? CalculateInterpoolCoefficient(player, opponent, rule, out collegeInterpoolApplied) : 1.0f;
            rr = a * b * c * d * f;
            float coef = 1.0f;

            if (againstBenchmark)
            {
                coef = (rule.EnableBenchmarkMatchCoeffecient) ? rule.BenchmarkMatchCoeffecient : 1.0f;
                rr   = rr * coef;
            }

            RatingInfo.WeightingFactors wf = new RatingInfo.WeightingFactors();
            wf.MatchFormatReliability          = b;
            wf.MatchFrequencyReliability       = c;
            wf.MatchCompetitivenessCoeffecient = d;
            wf.BenchmarkMatchCoeffecient       = coef;
            wf.OpponentRatingReliability       = a;
            wf.InterpoolCoeffecient            = f;
            // TESTING: use college interpool as match weight if it is applied
            //wf.MatchWeight = collegeInterpoolApplied ? (rule.interpoolCoefficientCollege*10) : (float)Math.Truncate(100000 * rr) / 100000;
            wf.MatchWeight = (float)Math.Truncate(100000 * rr) / 100000;
            return(wf);
        }