diff --git a/Algorithm/PathFinding/AStar.php b/Algorithm/PathFinding/AStar.php index 4d777dd78..52f8f9fe7 100644 --- a/Algorithm/PathFinding/AStar.php +++ b/Algorithm/PathFinding/AStar.php @@ -41,7 +41,7 @@ class JumpPointSearch implements PathFinderInterface $startNode->setF(0.0); $startNode->setOpened(true); - $openList = new Heap(function($node1, $node2) { return $node1->getF() - $nodeB->getF(); }); + $openList = new Heap(function($node1, $node2) { return $node1->getF() - $node2->getF(); }); $openList->push($startNode); $node = null; @@ -72,7 +72,7 @@ class JumpPointSearch implements PathFinderInterface if (!$neighbor->isOpened()) { $openList->push($neighbor); - $jumpPoint->setOpened(true); + $neighbor->setOpened(true); } else { $openList->update($neighbor); } diff --git a/Algorithm/PathFinding/Path.php b/Algorithm/PathFinding/Path.php index 529483e79..f032ae57e 100644 --- a/Algorithm/PathFinding/Path.php +++ b/Algorithm/PathFinding/Path.php @@ -27,7 +27,7 @@ class Path public array $nodes = []; private float $weight = 0.0; private float $distance = 0.0; - private ?Grid $grid = null; + private Grid $grid; public function __construct(Grid $grid) { @@ -42,7 +42,7 @@ class Path public function expandPath() : array { $reverse = \array_reverse($this->nodes); - $length = count($reverse); + $length = \count($reverse); if ($length < 2) { return $reverse; @@ -54,7 +54,7 @@ class Path $coord1 = $reverse[$i + 1]; $interpolated = $this->interpolate($coord0, $coord1); - $iLength = count($interpolated); + $iLength = \count($interpolated); $expanded = \array_merge($expanded, \array_slice($interpolated, 0, $iLength - 1)); }