From 65db7f64eae913ce20405f7b8b4901173d4b650f Mon Sep 17 00:00:00 2001 From: Jens True Date: Tue, 14 May 2024 11:12:26 +0000 Subject: [PATCH] Teams::concat was unnessecary --- benchmark/BasicBench.php | 8 +-- examples/3teams.php | 2 +- examples/basic.php | 2 +- src/Teams.php | 16 ------ tests/TeamsTest.php | 28 ---------- tests/TrueSkill/TrueSkillCalculatorTests.php | 54 ++++++++++---------- 6 files changed, 33 insertions(+), 77 deletions(-) delete mode 100644 src/Teams.php delete mode 100644 tests/TeamsTest.php diff --git a/benchmark/BasicBench.php b/benchmark/BasicBench.php index e585a60..6a136f7 100644 --- a/benchmark/BasicBench.php +++ b/benchmark/BasicBench.php @@ -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(); diff --git a/examples/3teams.php b/examples/3teams.php index 2113fb9..727ae98 100644 --- a/examples/3teams.php +++ b/examples/3teams.php @@ -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(); diff --git a/examples/basic.php b/examples/basic.php index 0afd0cf..1f5ec52 100644 --- a/examples/basic.php +++ b/examples/basic.php @@ -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(); diff --git a/src/Teams.php b/src/Teams.php deleted file mode 100644 index 6630b20..0000000 --- a/src/Teams.php +++ /dev/null @@ -1,16 +0,0 @@ -assertEquals([$t1], Teams::concat($t1)); - $this->assertEquals([$t1, $t2, $t3], Teams::concat($t1, $t2, $t3)); - } -} diff --git a/tests/TrueSkill/TrueSkillCalculatorTests.php b/tests/TrueSkill/TrueSkillCalculatorTests.php index 680a9e0..d8d669e 100644 --- a/tests/TrueSkill/TrueSkillCalculatorTests.php +++ b/tests/TrueSkill/TrueSkillCalculatorTests.php @@ -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);