mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-10-31 16:32:29 +01:00 
			
		
		
		
	Further slow progress.
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -5,4 +5,5 @@ nbproject | ||||
| vendor | ||||
| bin | ||||
| .phpunit.cache | ||||
| composer.phar | ||||
| composer.phar | ||||
| output/ | ||||
| @@ -24,7 +24,7 @@ | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "test":           "vendor/bin/phpunit tests --display-warnings", | ||||
|     "test-coverage":  "vendor/bin/phpunit tests --testdox --coverage-filter src --coverage-html output/coverage --coverage-text --path-coverage --testdox-html output/test.html  --log-junit output/test.xml ",  | ||||
|     "test-coverage":  "vendor/bin/phpunit tests --testdox --coverage-filter src --coverage-html output/coverage --coverage-text --testdox-html output/test.html  --log-junit output/test.xml",  | ||||
|     "analyze": [ | ||||
|         "@analyze-phpstan", | ||||
|         "@analyze-psalm", | ||||
|   | ||||
							
								
								
									
										574
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										574
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										41
									
								
								examples/3teams.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								examples/3teams.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| <?php | ||||
|  | ||||
| require_once("vendor/autoload.php"); | ||||
|  | ||||
| use DNW\Skills\TrueSkill\FactorGraphTrueSkillCalculator; | ||||
| use DNW\Skills\GameInfo; | ||||
| use DNW\Skills\Player; | ||||
| use DNW\Skills\Team; | ||||
| use DNW\Skills\Teams; | ||||
|  | ||||
| $gameInfo = new GameInfo(); | ||||
|  | ||||
| $p1 = new Player("Winner"); | ||||
| $p2 = new Player("Average"); | ||||
| $p3 = new Player("Looser"); | ||||
|  | ||||
|  | ||||
| $team1 = new Team($p1, $gameInfo->getDefaultRating()); | ||||
| $team2 = new Team($p2, $gameInfo->getDefaultRating()); | ||||
| $team3 = new Team($p3, $gameInfo->getDefaultRating()); | ||||
|  | ||||
|  | ||||
| for($i = 0; $i < 5; $i++) { | ||||
|     echo "Iteration: $i\n"; | ||||
|     $teams = Teams::concat($team1, $team2, $team3); | ||||
|  | ||||
|     $calculator = new FactorGraphTrueSkillCalculator(); | ||||
|  | ||||
|     $newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2, 3]); | ||||
|  | ||||
|     $team1 = new Team($p1, $newRatings->getRating($p1)); | ||||
|     $team2 = new Team($p2, $newRatings->getRating($p2)); | ||||
|     $team3 = new Team($p3, $newRatings->getRating($p3)); | ||||
|  | ||||
|     echo "P1: ". $newRatings->getRating($p1)->getConservativeRating() . PHP_EOL; | ||||
|     echo "P2: ". $newRatings->getRating($p2)->getConservativeRating() . PHP_EOL; | ||||
|     echo "P3: ". $newRatings->getRating($p3)->getConservativeRating() . PHP_EOL; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| @@ -12,13 +12,13 @@ $gameInfo = new GameInfo(); | ||||
|  | ||||
| $p1 = new Player("Winner"); | ||||
| $p2 = new Player("Average"); | ||||
| $p3 = new Player("Looser"); | ||||
|  | ||||
|  | ||||
| $team1 = new Team($p1, $gameInfo->getDefaultRating()); | ||||
|  | ||||
| $team2 = new Team($p2, $gameInfo->getDefaultRating()); | ||||
|  | ||||
|  | ||||
| for($i = 0; $i < 5; $i++) { | ||||
|     echo "Iteration: $i\n"; | ||||
|     $teams = Teams::concat($team1, $team2); | ||||
|   | ||||
| @@ -6,7 +6,7 @@ class FactorGraph | ||||
| { | ||||
|     private VariableFactory $variableFactory; | ||||
|  | ||||
|     public function __construct(VariableFactory $factory)  | ||||
|     public function __construct(VariableFactory $factory) | ||||
|     { | ||||
|         $this->variableFactory = $factory; | ||||
|     } | ||||
|   | ||||
| @@ -36,7 +36,7 @@ class GaussianWeightedSumFactor extends GaussianFactor | ||||
|      * @param Variable[] $variablesToSum | ||||
|      * @param array<float> $variableWeights | ||||
|      */ | ||||
|     public function __construct(Variable $sumVariable, array $variablesToSum, array $variableWeights = null) | ||||
|     public function __construct(Variable $sumVariable, array $variablesToSum, array $variableWeights) | ||||
|     { | ||||
|         parent::__construct(self::createName((string)$sumVariable, $variablesToSum, $variableWeights)); | ||||
|  | ||||
|   | ||||
							
								
								
									
										27
									
								
								tests/GuardTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								tests/GuardTest.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| <?php | ||||
|  | ||||
| namespace DNW\Skills\Tests; | ||||
|  | ||||
| use DNW\Skills\Guard; | ||||
| use Exception; | ||||
| class GuardTest extends TestCase | ||||
| { | ||||
|     public function testArgumentNotNull(): void | ||||
|     { | ||||
|         $this->expectException(Exception::class); | ||||
|         Guard::argumentNotNull(null, "dummy"); | ||||
|     } | ||||
|  | ||||
|     public function testargumentIsValidIndex(): void | ||||
|     { | ||||
|         $this->expectException(Exception::class); | ||||
|         Guard::argumentIsValidIndex(25, 10, "dummy"); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public function testargumentInRangeInclusive(): void | ||||
|     { | ||||
|         $this->expectException(Exception::class); | ||||
|         Guard::argumentInRangeInclusive(101, 0, 100, "dummy"); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user