| Conditions | 4 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 33 | public function solve(Puzzle $puzzle): Solutions |
||
| 34 | { |
||
| 35 | $search = $this->strategy->begin($puzzle); |
||
| 36 | $solutions = []; |
||
| 37 | |||
| 38 | while ($search->isOngoing()) { |
||
| 39 | $puzzleState = $search->nextCandidate(); |
||
| 40 | |||
| 41 | if ($puzzleState->isSolved()) { |
||
| 42 | $solutions[] = PuzzleSolution::fromSolved($puzzleState, $puzzle); |
||
| 43 | } |
||
| 44 | |||
| 45 | foreach ($puzzleState->possibleMoves() as $move) { |
||
| 46 | $search->consider($puzzleState->afterMaking($move)); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return new Solutions(...$solutions); |
||
| 51 | } |
||
| 53 |