コード例 #1
0
        public void ReturnsSameLoserRatingWithIterationsAndSingleCall()
        {
            var formula    = new EloFormula();
            var initialW   = 1400d;
            var initialL   = 1234d;
            var iterations = 500u;

            double LoserRatingAfterIterations()
            {
                var one    = 1u;
                var winner = initialW;
                var loser  = initialL;

                for (var i = 0; i < iterations; ++i)
                {
                    var w = winner;
                    var l = loser;

                    winner = formula !.WinnerNewRating(w, new[] { new DefaultMatch(l, one) });
                    loser  = formula.LoserNewRating(l, new DefaultMatch(w, one));
                }

                return(loser);
            }

            Assert.Equal(
                formula.LoserNewRating(initialL, new DefaultMatch(initialW, iterations)),
                LoserRatingAfterIterations(),
                6);
        }
コード例 #2
0
        public void DoesntChangeRatingSum()
        {
            var formula = new EloFormula(2d, 400d, 1500d);
            var winner  = formula.DefaultRating();
            var loser   = formula.DefaultRating();
            var count   = 500u;

            var w = winner;
            var l = loser;

            winner = formula.WinnerNewRating(w, new[] { new DefaultMatch(l, count) });
            loser  = formula.LoserNewRating(l, new DefaultMatch(w, count));

            Assert.Equal(w + l, winner + loser, 5);
        }
コード例 #3
0
        public void ReturnsPositiveRatingAfterManyLoses()
        {
            var formula = new EloFormula(2d, 400d, 1500d);
            var winner  = formula.DefaultRating();
            var loser   = formula.DefaultRating();
            var count   = 10u;

            for (var i = 0; i < 500; ++i)
            {
                var w = winner;
                var l = loser;

                winner = formula.WinnerNewRating(w, new[] { new DefaultMatch(l, count) });
                loser  = formula.LoserNewRating(l, new DefaultMatch(w, count));
            }

            Assert.True(loser > 0);
        }
コード例 #4
0
        public void DoesntChangeRatingSumOfThree()
        {
            var formula = new EloFormula(2d, 400d, 1500d);
            var first   = formula.DefaultRating();
            var second  = formula.DefaultRating();
            var three   = formula.DefaultRating();

            var f = first;
            var s = second;
            var t = three;

            first = formula.WinnerNewRating(f, new[]
            {
                new DefaultMatch(s, 110),
                new DefaultMatch(t, 19),
            });
            second = formula.LoserNewRating(s, new DefaultMatch(f, 110));
            three  = formula.LoserNewRating(t, new DefaultMatch(f, 19));

            Assert.Equal(f + s + t, first + second + three, 5);
        }