Example #1
0
        private Ranking[] GetMatchResult( User current, User user, BattleResult result )
        {
            Ranking one = new Ranking();
            one.EloRanking = current.EloRanking;
            Ranking two = new Ranking();
            two.EloRanking = user.EloRanking;

            Ranking.Update(one, two, result);

            return new Ranking[] { one, two };
        }
Example #2
0
        protected void Calculate( object sender, EventArgs args )
        {
            try{
                BattleResult result = GetResult();

                Ranking one = new Ranking();
                one.EloRanking = int.Parse( rank1.Text );

                Ranking two = new Ranking();
                two.EloRanking = int.Parse( rank2.Text );

                Ranking.Update(one, two, result);

                rank1Label.Text = one.EloRanking.ToString();
                rank2Label.Text = two.EloRanking.ToString();

            } catch( Exception ex)  {
                userRank.Text ="Error <!-- " + ex.ToString() + "-->";
            }
        }
Example #3
0
        public static int FinalScore( Ranking rank, double real, double expected, double distance )
        {
            if( distance < 0 ) {
                distance *= -1;
                distance += 1;
            } else {
                distance = 1;
            }

            double dif = expected - real;
            //Chronos.Utils.Log.log("*{3}* Dif: {0}={1} - {2}", dif, expected, real, rank.EloRanking );
            double withMod = rank.EloRankingModifier * distance * dif;
            //Chronos.Utils.Log.log("*{3}* withMod: {0}={1} - {2}", withMod, rank.EloRankingModifier, dif, rank.EloRanking );

            return (int) Math.Round(rank.EloRanking + withMod);
        }
Example #4
0
        public static void Update( Ranking one, Ranking two, BattleResult result )
        {
            double expectedOne = 0.5;
            double expectedTwo = 0.5;

            if( result != BattleResult.Draw ) {
                expectedOne = (result == BattleResult.NumberOneVictory) ? 1 : 0;
                expectedTwo = (result == BattleResult.NumberTwoVictory) ? 1 : 0;
            }

            double realOne = RealScore(one, two);
            double realTwo = RealScore(two, one);

            double oneDistance = (one.EloRanking - two.EloRanking) / 200 * expectedOne;
            double twoDistance = (two.EloRanking - one.EloRanking) / 200 * expectedTwo;

            one.EloRanking = FinalScore(one, realOne, expectedOne, oneDistance);
            two.EloRanking = FinalScore(two, realTwo, expectedTwo, twoDistance);
        }
Example #5
0
        public static void Update( AllianceInfo one, AllianceInfo two, BattleResult result )
        {
            Ranking r1 = new Ranking();
            r1.EloRanking = one.Ranking;

            Ranking r2 = new Ranking();
            r2.EloRanking = two.Ranking;

            Update( r1, r2, result );

            one.Ranking = r1.EloRanking;
            two.Ranking = r2.EloRanking;
        }
Example #6
0
        public static double RealScore( Ranking asker, Ranking other )
        {
            int exp = (int)Math.Round((other.EloRanking - asker.EloRanking) / 400.0);
            double factor = 1 + System.Math.Pow(10, exp);

            factor = 1.0 / factor;
            return factor;
        }