Exemplo n.º 1
0
        public void ReturnsSameWinnerRatingWithIterationsAndSingleCall()
        {
            var formula    = new EloFormula();
            var initialW   = 1400d;
            var initialL   = 1234d;
            var iterations = 500u;

            double WinnerRatingAfterIterations()
            {
                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(winner);
            }

            Assert.Equal(
                formula.WinnerNewRating(initialW, new[] { new DefaultMatch(initialL, iterations) }),
                WinnerRatingAfterIterations(),
                6);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }