Teams::concat was unnessecary

This commit is contained in:
Jens True 2024-05-14 11:12:26 +00:00
parent 5cf6acdfb1
commit 65db7f64ea
6 changed files with 33 additions and 77 deletions

@ -31,7 +31,7 @@ class BasicBench
$team2 = new Team($p2, $gameInfo->getDefaultRating());
for ($i = 0; $i < 10; ++$i) {
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$calculator = new TwoPlayerTrueSkillCalculator();
@ -62,7 +62,7 @@ class BasicBench
$team2 = new Team($p2, $gameInfo->getDefaultRating());
for ($i = 0; $i < 10; ++$i) {
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$calculator = new TwoTeamTrueSkillCalculator();
@ -93,7 +93,7 @@ class BasicBench
$team2 = new Team($p2, $gameInfo->getDefaultRating());
for ($i = 0; $i < 10; ++$i) {
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$calculator = new FactorGraphTrueSkillCalculator();
@ -126,7 +126,7 @@ class BasicBench
$team3 = new Team($p3, $gameInfo->getDefaultRating());
for ($i = 0; $i < 10; ++$i) {
$teams = Teams::concat($team1, $team2, $team3);
$teams = [$team1, $team2, $team3];
$calculator = new FactorGraphTrueSkillCalculator();

@ -22,7 +22,7 @@ $team3 = new Team($p3, $gameInfo->getDefaultRating());
for($i = 0; $i < 5; ++$i) {
echo "Iteration: " . $i . PHP_EOL;
$teams = Teams::concat($team1, $team2, $team3);
$teams = [$team1, $team2, $team3];
$calculator = new FactorGraphTrueSkillCalculator();

@ -21,7 +21,7 @@ $team2 = new Team($p2, $gameInfo->getDefaultRating());
for($i = 0; $i < 5; ++$i) {
echo "Iteration: " . $i . PHP_EOL;
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$calculator = new TwoPlayerTrueSkillCalculator();

@ -1,16 +0,0 @@
<?php
declare(strict_types=1);
namespace DNW\Skills;
class Teams
{
/**
* @return Team[]
*/
public static function concat(Team ...$args/*variable arguments*/): array
{
return $args;
}
}

@ -1,28 +0,0 @@
<?php
declare(strict_types=1);
namespace DNW\Skills\Tests;
use DNW\Skills\Teams;
use DNW\Skills\Team;
use DNW\Skills\RatingContainer;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
#[CoversClass(Teams::class)]
#[UsesClass(Team::class)]
#[UsesClass(RatingContainer::class)]
class TeamsTest extends TestCase
{
public function testTeamsConcat(): void
{
$t1 = new Team();
$t2 = new Team();
$t3 = new Team();
$this->assertEquals([$t1], Teams::concat($t1));
$this->assertEquals([$t1, $t2, $t3], Teams::concat($t1, $t2, $t3));
}
}

@ -86,7 +86,7 @@ class TrueSkillCalculatorTests
$team1 = new Team($player1, $gameInfo->getDefaultRating());
$team2 = new Team($player2, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
@ -109,7 +109,7 @@ class TrueSkillCalculatorTests
$team1 = new Team($player1, $gameInfo->getDefaultRating());
$team2 = new Team($player2, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 1]);
@ -132,7 +132,7 @@ class TrueSkillCalculatorTests
$team1 = new Team($player1, new Rating(1301.0007, 42.9232));
$team2 = new Team($player2, new Rating(1188.7560, 42.5570));
$newRatings = $calculator->calculateNewRatings($gameInfo, Teams::concat($team1, $team2), [1, 2]);
$newRatings = $calculator->calculateNewRatings($gameInfo, [$team1, $team2], [1, 2]);
$player1NewRating = $newRatings->getRating($player1);
self::assertRating($testClass, 1304.7820836053318, 42.843513887848658, $player1NewRating);
@ -153,7 +153,7 @@ class TrueSkillCalculatorTests
$team2 = new Team($player2, new Rating(50, 12.5));
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 1]);
@ -184,7 +184,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player2, $gameInfo->getDefaultRating());
$team2->addPlayer($player3, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
// Winners
@ -219,7 +219,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player3, $gameInfo->getDefaultRating());
$team2->addPlayer($player4, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
// Winners
@ -249,7 +249,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player2, new Rating(20, 7));
$team2->addPlayer($player3, new Rating(25, 8));
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
// Winners
@ -280,7 +280,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player3, $gameInfo->getDefaultRating());
$team2->addPlayer($player4, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
// Winners
@ -310,7 +310,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player2, $gameInfo->getDefaultRating());
$team2->addPlayer($player3, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 1]);
// Winners
@ -341,7 +341,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player3, $gameInfo->getDefaultRating());
$team2->addPlayer($player4, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 1]);
// Winners
@ -381,7 +381,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player7, $gameInfo->getDefaultRating());
$team2->addPlayer($player8, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
// Winners
@ -419,7 +419,7 @@ class TrueSkillCalculatorTests
$gameInfo = new GameInfo();
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLoseExpected = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
// Winners
@ -431,7 +431,7 @@ class TrueSkillCalculatorTests
self::assertRating($testClass, 29.785, 3.958, $newRatingsWinLoseExpected->getRating($player4));
self::assertRating($testClass, 30.879, 2.983, $newRatingsWinLoseExpected->getRating($player5));
$newRatingsWinLoseUpset = $calculator->calculateNewRatings($gameInfo, Teams::concat($team1, $team2), [2, 1]);
$newRatingsWinLoseUpset = $calculator->calculateNewRatings($gameInfo, [$team1, $team2], [2, 1]);
// Winners
self::assertRating($testClass, 32.012, 3.877, $newRatingsWinLoseUpset->getRating($player4));
@ -463,7 +463,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player3, new Rating(25, 4));
$team2->addPlayer($player4, new Rating(30, 3));
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 1]);
// Winners
@ -495,7 +495,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player3, new Rating(35, 7));
$team2->addPlayer($player4, new Rating(40, 5));
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
// Winners
@ -535,7 +535,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player7, $gameInfo->getDefaultRating());
$team2->addPlayer($player8, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
@ -572,7 +572,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($player3, $gameInfo->getDefaultRating());
$team2->addPlayer($player4, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 1]);
// Winners
@ -598,7 +598,7 @@ class TrueSkillCalculatorTests
$team2 = new Team($player2, $gameInfo->getDefaultRating());
$team3 = new Team($player3, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2, $team3);
$teams = [$team1, $team2, $team3];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2, 3]);
$player1NewRating = $newRatings->getRating($player1);
@ -625,7 +625,7 @@ class TrueSkillCalculatorTests
$team2 = new Team($player2, $gameInfo->getDefaultRating());
$team3 = new Team($player3, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2, $team3);
$teams = [$team1, $team2, $team3];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 1, 1]);
$player1NewRating = $newRatings->getRating($player1);
@ -653,7 +653,7 @@ class TrueSkillCalculatorTests
$team3 = new Team($player3, $gameInfo->getDefaultRating());
$team4 = new Team($player4, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2, $team3, $team4);
$teams = [$team1, $team2, $team3, $team4];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2, 3, 4]);
@ -687,7 +687,7 @@ class TrueSkillCalculatorTests
$team4 = new Team($player4, $gameInfo->getDefaultRating());
$team5 = new Team($player5, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2, $team3, $team4, $team5);
$teams = [$team1, $team2, $team3, $team4, $team5];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2, 3, 4, 5]);
$player1NewRating = $newRatings->getRating($player1);
@ -729,7 +729,7 @@ class TrueSkillCalculatorTests
$team7 = new Team($player7, $gameInfo->getDefaultRating());
$team8 = new Team($player8, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2, $team3, $team4, $team5, $team6, $team7, $team8);
$teams = [$team1, $team2, $team3, $team4, $team5, $team6, $team7, $team8];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 1, 1, 1, 1, 1, 1, 1]);
$player1NewRating = $newRatings->getRating($player1);
@ -781,7 +781,7 @@ class TrueSkillCalculatorTests
$team7 = new Team($player7, new Rating(40, 2));
$team8 = new Team($player8, new Rating(45, 1));
$teams = Teams::concat($team1, $team2, $team3, $team4, $team5, $team6, $team7, $team8);
$teams = [$team1, $team2, $team3, $team4, $team5, $team6, $team7, $team8];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2, 3, 4, 5, 6, 7, 8]);
$player1NewRating = $newRatings->getRating($player1);
@ -849,7 +849,7 @@ class TrueSkillCalculatorTests
$team15 = new Team($player15, $gameInfo->getDefaultRating());
$team16 = new Team($player16, $gameInfo->getDefaultRating());
$teams = Teams::concat(
$teams = [
$team1,
$team2,
$team3,
@ -866,7 +866,7 @@ class TrueSkillCalculatorTests
$team14,
$team15,
$team16
);
];
$newRatings = $calculator->calculateNewRatings(
$gameInfo,
@ -952,7 +952,7 @@ class TrueSkillCalculatorTests
$team3->addPlayer($player7, new Rating(50, 5));
$team3->addPlayer($player8, new Rating(30, 2));
$teams = Teams::concat($team1, $team2, $team3);
$teams = [$team1, $team2, $team3];
$newRatingsWinLose = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2, 2]);
// Winners
@ -986,7 +986,7 @@ class TrueSkillCalculatorTests
$team2->addPlayer($p2, $gameInfo->getDefaultRating());
$team2->addPlayer($p3, $gameInfo->getDefaultRating());
$teams = Teams::concat($team1, $team2);
$teams = [$team1, $team2];
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
$p1NewRating = $newRatings->getRating($p1);