Files
trueskill/src/FactorGraphs/ScheduleLoop.php

24 lines
595 B
PHP
Raw Normal View History

2022-07-05 15:55:47 +02:00
<?php
namespace DNW\Skills\FactorGraphs;
class ScheduleLoop extends Schedule
{
2022-07-05 16:21:06 +02:00
public function __construct($name, private readonly Schedule $_scheduleToLoop, private $_maxDelta)
{
parent::__construct($name);
}
2023-08-01 12:13:24 +00:00
public function visit(int $depth = -1, int $maxDepth = 0)
{
$totalIterations = 1;
$delta = $this->_scheduleToLoop->visit($depth + 1, $maxDepth);
while ($delta > $this->_maxDelta) {
$delta = $this->_scheduleToLoop->visit($depth + 1, $maxDepth);
$totalIterations++;
}
return $delta;
}
2022-07-05 15:55:47 +02:00
}