@@ -45,7 +45,7 @@ |
||
| 45 | 45 | return Moves::none(); |
| 46 | 46 | } |
| 47 | 47 | [$r, $c] = $this->firstEmptyPosition; |
| 48 | - return Entry::allPossibilitiesFor($r, $c)->filterWith(function (Entry $entry) { |
|
| 48 | + return Entry::allPossibilitiesFor($r, $c)->filterWith(function(Entry $entry) { |
|
| 49 | 49 | return $this->allows($entry); |
| 50 | 50 | }); |
| 51 | 51 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | public static function allPossibilitiesFor(int $row, int $column): Moves |
| 27 | 27 | { |
| 28 | 28 | return new Moves(...array_map( |
| 29 | - static function (int $number) use ($row, $column): Entry { |
|
| 29 | + static function(int $number) use ($row, $column): Entry { |
|
| 30 | 30 | return new self($number, $row, $column); |
| 31 | 31 | }, |
| 32 | 32 | range(1, 9) |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | foreach ($crateCoordinates as $id => $coordinates) { |
| 68 | 68 | $crates[] = Crate::fromCoordinates($id, ...$coordinates); |
| 69 | 69 | } |
| 70 | - usort($crates, static function (Crate $crate1, Crate $crate2): int { |
|
| 70 | + usort($crates, static function(Crate $crate1, Crate $crate2): int { |
|
| 71 | 71 | return $crate1->id() <=> $crate2->id(); |
| 72 | 72 | }); |
| 73 | 73 | |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | public function possiblePushes(): Moves |
| 71 | 71 | { |
| 72 | 72 | return Push::allFor($this->crates) |
| 73 | - ->filterWith(function (Push $push): bool { |
|
| 73 | + ->filterWith(function(Push $push): bool { |
|
| 74 | 74 | return $this->crates->withId($push->crateId())->canPush( |
| 75 | 75 | $push, |
| 76 | 76 | $this->crates, |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | public function possibleMoves(): Moves |
| 51 | 51 | { |
| 52 | - return Action::all()->filterWith(function (Action $action) { |
|
| 52 | + return Action::all()->filterWith(function(Action $action) { |
|
| 53 | 53 | return $this->maze->isValidPosition($this->hero->after($action)); |
| 54 | 54 | }); |
| 55 | 55 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | { |
| 25 | 25 | return new Moves( |
| 26 | 26 | new Crossing($riverbank->isStart(), null), |
| 27 | - ...array_map(static function (Purchase $purchase) use ($riverbank) { |
|
| 27 | + ...array_map(static function(Purchase $purchase) use ($riverbank) { |
|
| 28 | 28 | return new Crossing($riverbank->isStart(), $purchase); |
| 29 | 29 | }, $riverbank->purchases()) |
| 30 | 30 | ); |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | public function possibleCrossings(): Moves |
| 38 | 38 | { |
| 39 | 39 | return Crossing::allCrossingsFor($this->currentBank) |
| 40 | - ->filterWith(function (Crossing $crossing) { |
|
| 40 | + ->filterWith(function(Crossing $crossing) { |
|
| 41 | 41 | return $this->currentBank->canTakeAway($crossing->bringAlong()); |
| 42 | 42 | }); |
| 43 | 43 | } |
@@ -26,8 +26,7 @@ discard block |
||
| 26 | 26 | SearchSettings $settings |
| 27 | 27 | ): PuzzleSolver { |
| 28 | 28 | return $puzzle->singleSolution() ? |
| 29 | - EagerSolver::using($this->add($settings, $this->eagerStrategy($puzzle))) : |
|
| 30 | - LazySolver::using($this->add($settings, $this->lazyStrategy($puzzle))); |
|
| 29 | + EagerSolver::using($this->add($settings, $this->eagerStrategy($puzzle))) : LazySolver::using($this->add($settings, $this->lazyStrategy($puzzle))); |
|
| 31 | 30 | } |
| 32 | 31 | |
| 33 | 32 | private function add( |
@@ -67,8 +66,7 @@ discard block |
||
| 67 | 66 | } |
| 68 | 67 | return VisitedNodeSkipperFactory::using( |
| 69 | 68 | $puzzle->isExhausting() ? |
| 70 | - DepthFirstStrategyFactory::make() : |
|
| 71 | - BreadthFirstStrategyFactory::make() |
|
| 69 | + DepthFirstStrategyFactory::make() : BreadthFirstStrategyFactory::make() |
|
| 72 | 70 | ); |
| 73 | 71 | } |
| 74 | 72 | |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | isset($puzzle['heuristic']) ? new $puzzle['heuristic']() : null |
| 42 | 42 | ); |
| 43 | 43 | $renderer = ($puzzle['display'] ?? 'states') === 'states' ? |
| 44 | - PuzzleStatesToFileRenderer::fromFilenameAndSeparator(OUT, $sep, $time) : |
|
| 45 | - MovesToFileRenderer::fromFilenameAndSeparator(OUT, $sep, $time); |
|
| 44 | + PuzzleStatesToFileRenderer::fromFilenameAndSeparator(OUT, $sep, $time) : MovesToFileRenderer::fromFilenameAndSeparator(OUT, $sep, $time); |
|
| 46 | 45 | |
| 47 | 46 | $puzzleInfo[$puzzle['name']] = []; |
| 48 | 47 | foreach (scandir($dir) as $file) { |
@@ -54,7 +53,7 @@ discard block |
||
| 54 | 53 | 'factory' => $factories[$puzzle['type']], |
| 55 | 54 | 'description' => $description, |
| 56 | 55 | 'renderer' => $renderer, |
| 57 | - 'isDefault' => (($puzzle['default'] ?? '') . '.txt') === $file, |
|
| 56 | + 'isDefault' => (($puzzle['default'] ?? '') . '.txt') === $file, |
|
| 58 | 57 | 'isTheOnlyOne' => (bool) ($puzzle['level'] ?? false), |
| 59 | 58 | ]; |
| 60 | 59 | } |