From c9e439c0f48da6f7e0db3824d737bca3666b22cc Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 4 Sep 2019 20:39:29 +0200 Subject: [PATCH] Fix bugs/typos --- Algorithm/PathFinding/AStar.php | 4 ++-- Algorithm/PathFinding/Path.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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)); }