mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Jens True
46dcbed28b
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DNW\Skills\Tests;
|
|
|
|
use DNW\Skills\Rating;
|
|
use DNW\Skills\Numerics\BasicMath;
|
|
use DNW\Skills\Numerics\GaussianDistribution;
|
|
use PHPUnit\Framework\TestCase;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\UsesClass;
|
|
|
|
#[CoversClass(Rating::class)]
|
|
#[UsesClass(BasicMath::class)]
|
|
#[UsesClass(GaussianDistribution::class)]
|
|
class RatingTest extends TestCase
|
|
{
|
|
public function testGetRatingParameters(): void
|
|
{
|
|
$rating = new Rating(100, 10, 5);
|
|
$this->assertEquals(100, $rating->getMean());
|
|
$this->assertEquals(10, $rating->getStandardDeviation());
|
|
$this->assertEquals(50, $rating->getConservativeRating());
|
|
}
|
|
|
|
public function testPartialUpdate(): void
|
|
{
|
|
$rating = new Rating(100, 10, 5);
|
|
$ratingOld = new Rating(100, 10, 5);
|
|
$ratingNew = new Rating(200, 10, 5);
|
|
|
|
$rating_partial = $rating->getPartialUpdate($ratingOld, $ratingNew, 0.5);
|
|
|
|
$this->assertEquals(150, $rating_partial->getMean());
|
|
$this->assertEquals(10, $rating_partial->getStandardDeviation());
|
|
$this->assertEquals(100, $rating_partial->getConservativeRating());
|
|
}
|
|
}
|