mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
"lint": [
|
||||
"phplint",
|
||||
"phpcs",
|
||||
"phpcbf src/ tests/ benchmark/ examples/",
|
||||
"phpmd src/,tests/,benchmark/,examples/ text phpmd.ruleset.xml"
|
||||
],
|
||||
"analyze": [
|
||||
|
14
composer.lock
generated
14
composer.lock
generated
@ -2025,16 +2025,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "11.3.4",
|
||||
"version": "11.3.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "d2ef57db1410b102b250e0cdce6675a60c2a993d"
|
||||
"reference": "4dc07a589a68f8f2d5132ac0849146d122e08347"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d2ef57db1410b102b250e0cdce6675a60c2a993d",
|
||||
"reference": "d2ef57db1410b102b250e0cdce6675a60c2a993d",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4dc07a589a68f8f2d5132ac0849146d122e08347",
|
||||
"reference": "4dc07a589a68f8f2d5132ac0849146d122e08347",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2055,7 +2055,7 @@
|
||||
"phpunit/php-timer": "^7.0.1",
|
||||
"sebastian/cli-parser": "^3.0.2",
|
||||
"sebastian/code-unit": "^3.0.1",
|
||||
"sebastian/comparator": "^6.0.2",
|
||||
"sebastian/comparator": "^6.1.0",
|
||||
"sebastian/diff": "^6.0.2",
|
||||
"sebastian/environment": "^7.2.0",
|
||||
"sebastian/exporter": "^6.1.3",
|
||||
@ -2105,7 +2105,7 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.3.4"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.3.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -2121,7 +2121,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T06:08:34+00:00"
|
||||
"time": "2024-09-13T05:22:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psalm/plugin-phpunit",
|
||||
|
@ -20,7 +20,7 @@ $team2 = new Team($p2, $gameInfo->getDefaultRating());
|
||||
$team3 = new Team($p3, $gameInfo->getDefaultRating());
|
||||
|
||||
|
||||
for($i = 0; $i < 5; ++$i) {
|
||||
for ($i = 0; $i < 5; ++$i) {
|
||||
echo "Iteration: " . $i . PHP_EOL;
|
||||
$teams = [$team1, $team2, $team3];
|
||||
|
||||
@ -32,10 +32,7 @@ for($i = 0; $i < 5; ++$i) {
|
||||
$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;
|
||||
echo "P1: " . $newRatings->getRating($p1)->getConservativeRating() . PHP_EOL;
|
||||
echo "P2: " . $newRatings->getRating($p2)->getConservativeRating() . PHP_EOL;
|
||||
echo "P3: " . $newRatings->getRating($p3)->getConservativeRating() . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ $team1 = new Team($p1, $gameInfo->getDefaultRating());
|
||||
$team2 = new Team($p2, $gameInfo->getDefaultRating());
|
||||
|
||||
|
||||
for($i = 0; $i < 5; ++$i) {
|
||||
for ($i = 0; $i < 5; ++$i) {
|
||||
echo "Iteration: " . $i . PHP_EOL;
|
||||
$teams = [$team1, $team2];
|
||||
|
||||
@ -30,9 +30,6 @@ for($i = 0; $i < 5; ++$i) {
|
||||
$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;
|
||||
echo "P1: " . $newRatings->getRating($p1)->getConservativeRating() . PHP_EOL;
|
||||
echo "P2: " . $newRatings->getRating($p2)->getConservativeRating() . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -17,10 +17,11 @@ $csv->setDelimiter(',');
|
||||
$csv->setHeaderOffset(0);
|
||||
|
||||
//build a statement
|
||||
$stmt = Statement::create()->where(static fn (array $record): bool => $record['category']=="MotoGP" || $record['category']=="500cc");
|
||||
//$stmt = Statement::create();
|
||||
$stmt = Statement::create()->where(static fn (array $record): bool => $record['category'] == "MotoGP" || $record['category'] == "500cc");
|
||||
|
||||
/** @var $riders Player[] */
|
||||
/**
|
||||
* @var $riders Player[]
|
||||
*/
|
||||
$riders = [];
|
||||
//query your records from the document
|
||||
$records = $stmt->process($csv);
|
||||
@ -28,54 +29,48 @@ $records = $stmt->process($csv);
|
||||
$gameInfo = new GameInfo();
|
||||
$calculator = new FactorGraphTrueSkillCalculator();
|
||||
$first_record = $records->first();
|
||||
$year_race = $first_record['year'].'_'.$first_record['sequence'].'_'.$first_record['category'];
|
||||
$year_race = $first_record['year'] . '_' . $first_record['sequence'] . '_' . $first_record['category'];
|
||||
|
||||
$race_rate = [];
|
||||
foreach($records as $record)
|
||||
{
|
||||
if ($year_race !== $record['year'].'_'.$record['sequence'].'_'.$record['category'])
|
||||
{
|
||||
foreach ($records as $record) {
|
||||
if ($year_race !== $record['year'] . '_' . $record['sequence'] . '_' . $record['category']) {
|
||||
//Calculate the old race
|
||||
$newRatings = $calculator->calculateNewRatings($gameInfo, $teams, $pos);
|
||||
|
||||
//update ratings
|
||||
$highest_rate = 0;
|
||||
$highest_rider = "";
|
||||
foreach($riders as $rider) {
|
||||
foreach ($riders as $rider) {
|
||||
//echo $rider['P']->getId().": ". $newRatings->getRating($rider['P'])->getConservativeRating() . PHP_EOL;
|
||||
$rider['T']->setRating($rider['P'], $newRatings->getRating($rider['P']));
|
||||
if($newRatings->getRating($rider['P'])->getConservativeRating() > $highest_rate)
|
||||
{
|
||||
if ($newRatings->getRating($rider['P'])->getConservativeRating() > $highest_rate) {
|
||||
$highest_rate = $newRatings->getRating($rider['P'])->getConservativeRating();
|
||||
$highest_rider = $rider['P']->getId();
|
||||
}
|
||||
}
|
||||
|
||||
echo sprintf('Highest rider: %s => %s', $highest_rider, $highest_rate).PHP_EOL;
|
||||
echo sprintf('Highest rider: %s => %s', $highest_rider, $highest_rate) . PHP_EOL;
|
||||
|
||||
foreach($global_riders as $r)
|
||||
{
|
||||
foreach ($global_riders as $r) {
|
||||
$rate = $r['T']->getRating($r['P'])->getConservativeRating();
|
||||
|
||||
$race_rate[$year_race][$r['P']->getId()] = $rate;
|
||||
if (!isset($top_rating[$r['P']->getId()]) || $top_rating[$r['P']->getId()] < $rate)
|
||||
{
|
||||
if (! isset($top_rating[$r['P']->getId()]) || $top_rating[$r['P']->getId()] < $rate) {
|
||||
$top_rating[$r['P']->getId()] = $rate;
|
||||
}
|
||||
}
|
||||
|
||||
//prepare for next race
|
||||
$year_race = $record['year'].'_'.$record['sequence'].'_'.$record['category'];
|
||||
$races[] =['year' => $record['year'], 'race'=> $record['sequence'], 'circuit'=> $record['circuit_name']];
|
||||
echo "New Race: ".$year_race. ' => '. $record['circuit_name'].PHP_EOL;
|
||||
$year_race = $record['year'] . '_' . $record['sequence'] . '_' . $record['category'];
|
||||
$races[] = ['year' => $record['year'], 'race' => $record['sequence'], 'circuit' => $record['circuit_name']];
|
||||
echo "New Race: " . $year_race . ' => ' . $record['circuit_name'] . PHP_EOL;
|
||||
$riders = [];
|
||||
$teams = [];
|
||||
$pos = [];
|
||||
}
|
||||
|
||||
//Is it a new rider?
|
||||
if(!isset($global_riders[$record['rider']]))
|
||||
{
|
||||
//Is it a new rider?
|
||||
if (! isset($global_riders[$record['rider']])) {
|
||||
$global_riders[$record['rider']]['P'] = new Player($record['rider_name']);
|
||||
$global_riders[$record['rider']]['T'] = new Team($global_riders[$record['rider']]['P'], $gameInfo->getDefaultRating());
|
||||
//echo "New Rider: ". $record['rider'] . " => ".$global_riders[$record['rider']]['P']->getId().PHP_EOL;
|
||||
@ -88,10 +83,8 @@ foreach($records as $record)
|
||||
$pos[] = $record['position'] >= 1 ? $record['position'] : end($pos);
|
||||
}
|
||||
|
||||
echo "All time top score".PHP_EOL;
|
||||
echo "All time top score" . PHP_EOL;
|
||||
asort($top_rating);
|
||||
foreach($top_rating as $n=>$r)
|
||||
{
|
||||
echo sprintf('%s => %s', $n, $r).PHP_EOL;
|
||||
foreach ($top_rating as $n => $r) {
|
||||
echo sprintf('%s => %s', $n, $r) . PHP_EOL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user