コード例 #1
0
        public void match(player two, double gameOutcome)
        {
            double R = this.R;
            double RD = this.RD;
            double R2 = two.R;
            double RD2 = two.RD;
            double outcome = gameOutcome;

            // Constant Q
            double q = 0.0057565;

            // Several lines for readability
            double TripleSquareQ = 3 * q * q;
            double SquarePi = Math.PI * Math.PI;
            double SquareRD = RD * RD;
            // G func
            double g = 1 / (Math.Sqrt(1 + TripleSquareQ * SquareRD / SquarePi));

            // E(s|r, rj, RDj ) func on only one match
            double X = 1 / (1 + Math.Pow(10,
                (-((g * (R - R2)) / 400))));

            // d² variable
            double d = 1 / (Math.Pow(q, 2) * Math.Pow(g, 2) * X * (1 - X));

            // Several lines for readability
            double second = q / ((1 / Math.Pow(RD, 2)) + (1 / d));
            // New rating of this.player
            double newR = R + second * (g * (outcome - X));

            // New rating deviation of this.player
            double newRD = Math.Sqrt(Math.Pow(1 / Math.Pow(RD, 2) + (1 / d), -1));

            // Updating this.player variables
            this.R = newR;
            // Mark Glickman says it is recommended to put a minimum limit for RD
            // When the RD gets too low, the player's rating doesn't change enough
            this.RD = newRD < 50 ? 50 : newRD;

            // Player TWO is not updated !!
        }
コード例 #2
0
        public MainWindow()
        {
            // I didn't put this in the view for the sake of lazyness
            player one = new player()
            {
                R = 1200,
                RD = 60
            };
            player two = new player()
            {
                R = 1200,
                RD = 60
            };
            
            one.match(two, GameOutcome.WIN);
            Console.WriteLine("New rating is : " + one.R);
            Console.WriteLine("New RD is : " + one.RD);

           InitializeComponent();
        }