示例#1
0
        public void WinBefore500()
        {
            var elo = new EloCalculator(100, 100);

            elo.WinGamePlayerA();
            decimal newRatingA = (decimal)elo.RatingPlayerA;
            decimal newRatingB = (decimal)elo.RatingPlayerB;

            Assert.AreEqual(150, newRatingA);
            Assert.AreEqual(100, newRatingB);
        }
示例#2
0
        public void StrengthPlayerWin()
        {
            var elo = new EloCalculator(2000, 1000);

            elo.WinGamePlayerA();
            decimal newRatingA = (decimal)elo.RatingPlayerA;
            decimal newRatingB = (decimal)elo.RatingPlayerB;

            Assert.AreEqual(2000.315230918, (double)newRatingA, 0.00001);
            Assert.AreEqual(999.684769081, (double)newRatingB, 0.00001);
        }
示例#3
0
        public void StrengthPlayerWinOnWeakPlayer()
        {
            var elo = new EloCalculator(1000, 100);

            elo.WinGamePlayerA();
            decimal newRatingA = (decimal)elo.RatingPlayerA;
            decimal newRatingB = (decimal)elo.RatingPlayerB;

            Assert.AreEqual(1000.5591967308, (double)newRatingA, 0.00001);
            Assert.AreEqual(100, newRatingB);
        }
示例#4
0
        private void calculateElo(Game game, UserStats statsA, UserStats statsB)
        {
            var elo = new EloCalculator(statsA.Elo, statsB.Elo);

            if (game.ScoreA > game.ScoreB)
            {
                elo.WinGamePlayerA();
            }
            else if (game.ScoreA < game.ScoreB)
            {
                elo.WinGamePlayerB();
            }
            else
            {
                elo.DrawGame();
            }

            statsA.Elo = (decimal)elo.RatingPlayerA;
            statsB.Elo = (decimal)elo.RatingPlayerB;
        }
示例#5
0
        public ActionResult Forecast(ForecastViewModel vm)
        {
            vm.AvailablePlayers = getAvailablePlayersSelectListItems();

            var playerA = _userService.GetUser(vm.PlayerAId);
            var playerB = _userService.GetUser(vm.PlayerBId);

            vm.NamePlayerA = playerA.Name;
            vm.NamePlayerB = playerB.Name;

            vm.CurrentRatingPlayerA = (double)_statsService.GetUserStat(playerA.Id).Elo;
            vm.CurrentRatingPlayerB = (double)_statsService.GetUserStat(playerB.Id).Elo;

            var elo = new EloCalculator(vm.CurrentRatingPlayerA, vm.CurrentRatingPlayerB);

            vm.ChanceToWinPlayerA = elo.GetChanceToWinPlayerA() * 100;
            vm.ChanceToWinPlayerB = 100 - vm.ChanceToWinPlayerA;

            elo.WinGamePlayerA();
            vm.RatingPlayerAWinPlayerA = elo.RatingPlayerA;
            vm.RatingPlayerBWinPlayerA = elo.RatingPlayerB;

            elo = new EloCalculator(vm.CurrentRatingPlayerA, vm.CurrentRatingPlayerB);
            elo.WinGamePlayerB();
            vm.RatingPlayerAWinPlayerB = elo.RatingPlayerA;
            vm.RatingPlayerBWinPlayerB = elo.RatingPlayerB;

            elo = new EloCalculator(vm.CurrentRatingPlayerA, vm.CurrentRatingPlayerB);
            elo.DrawGame();
            vm.RatingPlayerADrawGame = elo.RatingPlayerA;
            vm.RatingPlayerBDrawGame = elo.RatingPlayerB;

            vm.Calculated = true;

            return(View(vm));
        }
示例#6
0
        private void calculateElo(Game game, UserStats statsA, UserStats statsB)
        {
            var elo = new EloCalculator(statsA.Elo, statsB.Elo);
            if (game.ScoreA > game.ScoreB)
            {
                elo.WinGamePlayerA();
            }
            else if (game.ScoreA < game.ScoreB)
            {
                elo.WinGamePlayerB();
            }
            else
            {
                elo.DrawGame();
            }

            statsA.Elo = (decimal)elo.RatingPlayerA;
            statsB.Elo = (decimal)elo.RatingPlayerB;
        }
示例#7
0
        public ActionResult Forecast(ForecastViewModel vm)
        {
            vm.AvailablePlayers = getAvailablePlayersSelectListItems();

            var playerA = _userService.GetUser(vm.PlayerAId);
            var playerB = _userService.GetUser(vm.PlayerBId);

            vm.NamePlayerA = playerA.Name;
            vm.NamePlayerB = playerB.Name;

            vm.CurrentRatingPlayerA = (double)_statsService.GetUserStat(playerA.Id).Elo;
            vm.CurrentRatingPlayerB = (double)_statsService.GetUserStat(playerB.Id).Elo;

            var elo = new EloCalculator(vm.CurrentRatingPlayerA, vm.CurrentRatingPlayerB);
            vm.ChanceToWinPlayerA = elo.GetChanceToWinPlayerA() * 100;
            vm.ChanceToWinPlayerB = 100 - vm.ChanceToWinPlayerA;

            elo.WinGamePlayerA();
            vm.RatingPlayerAWinPlayerA = elo.RatingPlayerA;
            vm.RatingPlayerBWinPlayerA = elo.RatingPlayerB;

            elo = new EloCalculator(vm.CurrentRatingPlayerA, vm.CurrentRatingPlayerB);
            elo.WinGamePlayerB();
            vm.RatingPlayerAWinPlayerB = elo.RatingPlayerA;
            vm.RatingPlayerBWinPlayerB = elo.RatingPlayerB;

            elo = new EloCalculator(vm.CurrentRatingPlayerA, vm.CurrentRatingPlayerB);
            elo.DrawGame();
            vm.RatingPlayerADrawGame = elo.RatingPlayerA;
            vm.RatingPlayerBDrawGame = elo.RatingPlayerB;

            vm.Calculated = true;

            return View(vm);
        }