Exemple #1
0
        public void StrengthPlayerDraw()
        {
            var elo = new EloCalculator(2000, 1000);

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

            Assert.AreEqual(2000.157615459, (double)newRatingA, 0.00001);
            Assert.AreEqual(1049.842384540, (double)newRatingB, 0.00001);
        }
Exemple #2
0
        public void DrawBefore500()
        {
            var elo = new EloCalculator(100, 100);

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

            Assert.AreEqual(125, newRatingA);
            Assert.AreEqual(125, newRatingB);
        }
Exemple #3
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;
        }
Exemple #4
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));
        }
Exemple #5
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;
        }
Exemple #6
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);
        }