Files
trueskill/src/FactorGraphs/ScheduleLoop.php

24 lines
574 B
PHP
Raw Normal View History

2022-07-05 15:55:47 +02:00
<?php
2024-02-02 14:53:38 +00:00
declare(strict_types=1);
2022-07-05 15:55:47 +02:00
namespace DNW\Skills\FactorGraphs;
class ScheduleLoop extends Schedule
{
2023-08-02 13:29:14 +00:00
public function __construct(string $name, private readonly Schedule $scheduleToLoop, private float $maxDelta)
{
parent::__construct($name);
}
2023-08-02 09:36:44 +00:00
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;
}
2022-07-05 15:55:47 +02:00
}