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

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

            Assert.AreEqual(1900.315230918, (double)newRatingA, 0.00001);
            Assert.AreEqual(1099.684769081, (double)newRatingB, 0.00001);
        }
Beispiel #2
0
        public void StrengthPlayerLossOnWeakPlayer()
        {
            var elo = new EloCalculator(1000, 100);

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

            Assert.AreEqual(900.55919673088, (double)newRatingA, 0.00001);
            Assert.AreEqual(199.4408032691, (double)newRatingB, 0.00001);
        }
Beispiel #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;
        }
Beispiel #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));
        }
Beispiel #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;
        }
Beispiel #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);
        }