mirror of
https://github.com/furyfire/trueskill.git
synced 2025-06-28 07:30:54 +00:00
24 lines
583 B
PHP
24 lines
583 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DNW\Skills\FactorGraphs;
|
|
|
|
class ScheduleLoop extends Schedule
|
|
{
|
|
public function __construct(string $name, private readonly Schedule $scheduleToLoop, private readonly float $maxDelta)
|
|
{
|
|
parent::__construct($name);
|
|
}
|
|
|
|
public function visit(int $depth = -1, int $maxDepth = 0): float
|
|
{
|
|
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
|
|
while ($delta > $this->maxDelta) {
|
|
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
|
|
}
|
|
|
|
return $delta;
|
|
}
|
|
}
|