0

問題:

http://www.newedenfaces.com/の下部に移動すると、プレーヤーのリーダーボードが表示されます。誰もが基本スコア1400から始めました。現在、データベースには 1100 人を超えるプレイヤーがおり、投票するたびに各 2 人がランダムに選ばれます。現在の最高評価は1572です。さらに、リーダーボードは非常に不安定です。今日だけトップ 10 に入っていた人は、現在 70+ の範囲にいます

スコアをもっと重要なものにしてほしい。リーダーボードのほとんどの人は、評価がわずかに離れており、評価さえある人もいます.

醜くて冗長なコードで申し訳ありません。後でリファクタリングする必要があります。

eloRating: function(winnerIndex) {

    var kFactor = 16;

    if (winnerIndex == 0) {
      // A won
      var ratingA = this.collection.at(0).get('rating');
      var ratingB = this.collection.at(1).get('rating');

      var scoreA = this.collection.at(0).get('wins');
      var scoreB = this.collection.at(1).get('wins');

      var expectedA = 1.0 / (1.0 + Math.pow(10, ((ratingA - ratingB) / 400)));
      var expectedB = 1.0 / (1.0 + Math.pow(10, ((ratingA - ratingB) / 400)));

      var newRatingA = ratingA + (kFactor * expectedA);
      var newRatingB = ratingB - (kFactor * expectedA);

      this.collection.at(0).set('rating', Math.round(newRatingA));
      this.collection.at(1).set('rating', Math.round(newRatingB));
    } else {
      // B won
      var ratingA = this.collection.at(0).get('rating');
      var ratingB = this.collection.at(1).get('rating');

      var scoreA = this.collection.at(0).get('wins');
      var scoreB = this.collection.at(1).get('wins');

      var expectedA = 1.0 / (1.0 + Math.pow(10, ((ratingB - ratingA) / 400)));
      var expectedB = 1.0 / (1.0 + Math.pow(10, ((ratingB - ratingA) / 400)));

      var newRatingA = ratingA - (kFactor * expectedA);
      var newRatingB = ratingB + (kFactor * expectedA);

      this.collection.at(0).set('rating', Math.round(newRatingA));
      this.collection.at(1).set('rating', Math.round(newRatingB));
    }
4

2 に答える 2