More return types. Basic example

This commit is contained in:
2023-08-02 09:04:56 +00:00
parent f0aa9413e1
commit 32b8a9d83e
13 changed files with 71 additions and 33 deletions

38
examples/basic.php Normal file
View File

@ -0,0 +1,38 @@
<?php
require_once("vendor/autoload.php");
use DNW\Skills\TrueSkill\TwoPlayerTrueSkillCalculator;
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());
for($i = 0; $i < 5; $i++) {
echo "Iteration: $i\n";
$teams = Teams::concat($team1, $team2);
$calculator = new TwoPlayerTrueSkillCalculator();
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, [1, 2]);
$team1 = new Team($p1, $newRatings->getRating($p1));
$team2 = new Team($p2, $newRatings->getRating($p2));
echo "P1: ". $newRatings->getRating($p1)->getConservativeRating() . PHP_EOL;
echo "P2: ". $newRatings->getRating($p2)->getConservativeRating() . PHP_EOL;
}