こんにちは、私は elo アルゴリズムを実装して、LAN 内のプレイヤーを評価したいと考えていました。私のphpスクリプトには以下が含まれています。
<?php
class Rating
{
const KFACTOR = 16;
protected $_ratingA;
protected $_ratingB;
protected $_scoreA;
protected $_scoreB;
protected $_expectedA;
protected $_expectedB;
protected $_newRatingA;
protected $_newRatingB;
public function __construct($ratingA,$ratingB,$scoreA,$scoreB)
{
$this->_ratingA = $ratingA;
$this->_ratingB = $ratingB;
$this->_scoreA = $scoreA;
$this->_scoreB = $scoreB;
$expectedScores = $this -> _getExpectedScores($this -> _ratingA,$this -> _ratingB);
$this->_expectedA = $expectedScores['a'];
$this->_expectedB = $expectedScores['b'];
$newRatings = $this ->_getNewRatings($this -> _ratingA, $this -> _ratingB, $this -> _expectedA, $this -> _expectedB, $this -> _scoreA, $this -> _scoreB);
$this->_newRatingA = $newRatings['a'];
$this->_newRatingB = $newRatings['b'];
}
public function setNewSettings($ratingA,$ratingB,$scoreA,$scoreB)
{
$this -> _ratingA = $ratingA;
$this -> _ratingB = $ratingB;
$this -> _scoreA = $scoreA;
$this -> _scoreB = $scoreB;
$expectedScores = $this -> _getExpectedScores($this -> _ratingA,$this -> _ratingB);
$this -> _expectedA = $expectedScores['a'];
$this -> _expectedB = $expectedScores['b'];
$newRatings = $this ->_getNewRatings($this -> _ratingA, $this -> _ratingB, $this -> _expectedA, $this -> _expectedB, $this -> _scoreA, $this -> _scoreB);
$this -> _newRatingA = $newRatings['a'];
$this -> _newRatingB = $newRatings['b'];
}
public function getNewRatings()
{
return array (
'a' => $this -> _newRatingA,
'b' => $this -> _newRatingB
);
}
protected function _getExpectedScores($ratingA,$ratingB)
{
$expectedScoreA = 1 / ( 1 + ( pow( 10 , ( $ratingB - $ratingA ) / 400 ) ) );
$expectedScoreB = 1 / ( 1 + ( pow( 10 , ( $ratingA - $ratingB ) / 400 ) ) );
return array (
'a' => $expectedScoreA,
'b' => $expectedScoreB
);
}
protected function _getNewRatings($ratingA,$ratingB,$expectedA,$expectedB,$scoreA,$scoreB)
{
$newRatingA = $ratingA + ( self::KFACTOR * ( $scoreA - $expectedA ) );
$newRatingB = $ratingB + ( self::KFACTOR * ( $scoreB - $expectedB ) );
return array (
'a' => $newRatingA,
'b' => $newRatingB
);
}
}
//first player won
$first_player_rating=200;
$second_player_rating=200;
$n=new Rating($first_pic_rating,$second_pic_rating,1400,1400);
$a=$n->getNewRatings();
var_dump($a);
?>
私は first_player_rating と second_player_rating の両方に 200 を与えましたが、これは間違っていますが、問題は、最初のプレイヤーが試合に勝ったばかりの場合、first_player_rating と second_player_rating の値はどれくらいであるべきかということです...