mirror of
https://github.com/furyfire/trueskill.git
synced 2025-03-19 00:08:37 +00:00
PHPUnit version bump and removed ELO
This commit is contained in:
@ -1,43 +0,0 @@
|
||||
<?php namespace DNW\Skills\Tests\Elo;
|
||||
|
||||
use DNW\Skills\Elo\EloRating;
|
||||
use DNW\Skills\Elo\FideEloCalculator;
|
||||
use DNW\Skills\GameInfo;
|
||||
use DNW\Skills\PairwiseComparison;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
|
||||
class EloAssert
|
||||
{
|
||||
const ERROR_TOLERANCE = 0.1;
|
||||
|
||||
public static function assertChessRating(
|
||||
TestCase $testClass,
|
||||
FideEloCalculator $twoPlayerEloCalculator,
|
||||
$player1BeforeRating,
|
||||
$player2BeforeRating,
|
||||
$player1Result,
|
||||
$player1AfterRating,
|
||||
$player2AfterRating)
|
||||
{
|
||||
$player1 = "Player1";
|
||||
$player2 = "Player2";
|
||||
|
||||
$teams = array(
|
||||
array($player1 => new EloRating($player1BeforeRating)),
|
||||
array($player2 => new EloRating($player2BeforeRating))
|
||||
);
|
||||
|
||||
$chessGameInfo = new GameInfo(1200, 0, 200);
|
||||
|
||||
$ranks = PairwiseComparison::getRankFromComparison($player1Result);
|
||||
|
||||
$result = $twoPlayerEloCalculator->calculateNewRatings(
|
||||
$chessGameInfo,
|
||||
$teams,
|
||||
$ranks
|
||||
);
|
||||
|
||||
$testClass->assertEquals($player1AfterRating, $result[$player1]->getMean(), '', self::ERROR_TOLERANCE);
|
||||
$testClass->assertEquals($player2AfterRating, $result[$player2]->getMean(), '', self::ERROR_TOLERANCE);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<?php namespace DNW\Skills\Tests\Elo;
|
||||
|
||||
use DNW\Skills\Elo\FideEloCalculator;
|
||||
use DNW\Skills\Elo\ProvisionalFideKFactor;
|
||||
use DNW\Skills\PairwiseComparison;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
|
||||
class FideEloCalculatorTest extends TestCase
|
||||
{
|
||||
public function testFideProvisionalEloCalculator()
|
||||
{
|
||||
// verified against http://ratings.fide.com/calculator_rtd.phtml
|
||||
$calc = new FideEloCalculator(new ProvisionalFideKFactor());
|
||||
|
||||
EloAssert::assertChessRating($this, $calc, 1200, 1500, PairwiseComparison::WIN, 1221.25, 1478.75);
|
||||
EloAssert::assertChessRating($this, $calc, 1200, 1500, PairwiseComparison::DRAW, 1208.75, 1491.25);
|
||||
EloAssert::assertChessRating($this, $calc, 1200, 1500, PairwiseComparison::LOSE, 1196.25, 1503.75);
|
||||
}
|
||||
|
||||
public function testFideNonProvisionalEloCalculator()
|
||||
{
|
||||
// verified against http://ratings.fide.com/calculator_rtd.phtml
|
||||
$calc = FideEloCalculator::createWithDefaultKFactor();
|
||||
|
||||
EloAssert::assertChessRating($this, $calc, 1200, 1200, PairwiseComparison::WIN, 1207.5, 1192.5);
|
||||
EloAssert::assertChessRating($this, $calc, 1200, 1200, PairwiseComparison::DRAW, 1200, 1200);
|
||||
EloAssert::assertChessRating($this, $calc, 1200, 1200, PairwiseComparison::LOSE, 1192.5, 1207.5);
|
||||
|
||||
EloAssert::assertChessRating($this, $calc, 2600, 2500, PairwiseComparison::WIN, 2603.6, 2496.4);
|
||||
EloAssert::assertChessRating($this, $calc, 2600, 2500, PairwiseComparison::DRAW, 2598.6, 2501.4);
|
||||
EloAssert::assertChessRating($this, $calc, 2600, 2500, PairwiseComparison::LOSE, 2593.6, 2506.4);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<?php namespace DNW\Skills\Tests;
|
||||
|
||||
class TestCase extends \PHPUnit_Framework_TestCase
|
||||
class TestCase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user