@@ -9,8 +9,8 @@ |
||
9 | 9 | |
10 | 10 | public function compare(Node $node, Node $goal) |
11 | 11 | { |
12 | - $deltaX = abs($node->getX() - $goal->getX()); |
|
13 | - $deltaY = abs($node->getY() - $goal->getY()); |
|
14 | - return $deltaX + $deltaY; |
|
12 | + $deltaX = abs($node->getX()-$goal->getX()); |
|
13 | + $deltaY = abs($node->getY()-$goal->getY()); |
|
14 | + return $deltaX+$deltaY; |
|
15 | 15 | } |
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -9,8 +9,8 @@ |
||
9 | 9 | public function compare(Node $node, Node $goal) |
10 | 10 | { |
11 | 11 | |
12 | - $deltaX = abs($node->getX() - $goal->getX()); |
|
13 | - $deltaY = abs($node->getY() - $goal->getY()); |
|
14 | - return sqrt($deltaX * $deltaX + $deltaY * $deltaY); |
|
12 | + $deltaX = abs($node->getX()-$goal->getX()); |
|
13 | + $deltaY = abs($node->getY()-$goal->getY()); |
|
14 | + return sqrt($deltaX * $deltaX+$deltaY * $deltaY); |
|
15 | 15 | } |
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -9,8 +9,8 @@ |
||
9 | 9 | public function compare(Node $node, Node $goal) |
10 | 10 | { |
11 | 11 | |
12 | - $deltaX = abs($node->getX() - $goal->getX()); |
|
13 | - $deltaY = abs($node->getY() - $goal->getY()); |
|
12 | + $deltaX = abs($node->getX()-$goal->getX()); |
|
13 | + $deltaY = abs($node->getY()-$goal->getY()); |
|
14 | 14 | return max($deltaX, $deltaY); |
15 | 15 | } |
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -36,16 +36,16 @@ |
||
36 | 36 | $y = $node->getY(); |
37 | 37 | |
38 | 38 | $neighbourLocations = [ |
39 | - [$y - 1, $x], |
|
40 | - [$y + 1, $x], |
|
41 | - [$y, $x - 1], |
|
42 | - [$y, $x + 1] |
|
39 | + [$y-1, $x], |
|
40 | + [$y+1, $x], |
|
41 | + [$y, $x-1], |
|
42 | + [$y, $x+1] |
|
43 | 43 | ]; |
44 | 44 | if ($diagonal) { |
45 | - $neighbourLocations[] = [$y - 1, $x - 1]; |
|
46 | - $neighbourLocations[] = [$y + 1, $x - 1]; |
|
47 | - $neighbourLocations[] = [$y - 1, $x + 1]; |
|
48 | - $neighbourLocations[] = [$y + 1, $x + 1]; |
|
45 | + $neighbourLocations[] = [$y-1, $x-1]; |
|
46 | + $neighbourLocations[] = [$y+1, $x-1]; |
|
47 | + $neighbourLocations[] = [$y-1, $x+1]; |
|
48 | + $neighbourLocations[] = [$y+1, $x+1]; |
|
49 | 49 | } |
50 | 50 | foreach ($neighbourLocations as $location) { |
51 | 51 | list($y, $x) = $location; |
@@ -73,14 +73,14 @@ |
||
73 | 73 | if ($neighbor->isClosed() || in_array($neighbor->getCosts(), $this->blocked)) { |
74 | 74 | continue; |
75 | 75 | } |
76 | - $score = $current->getScore() + $neighbor->getCosts(); |
|
76 | + $score = $current->getScore()+$neighbor->getCosts(); |
|
77 | 77 | $visited = $neighbor->isVisited(); |
78 | 78 | if (!$visited || $score < $neighbor->getScore()) { |
79 | 79 | $neighbor->visit(); |
80 | 80 | $neighbor->setParent($current); |
81 | 81 | $neighbor->setGuessedScore($this->heuristic->compare($neighbor, $end)); |
82 | 82 | $neighbor->setScore($score); |
83 | - $neighbor->setTotalScore($neighbor->getScore() + $neighbor->getGuessedScore()); |
|
83 | + $neighbor->setTotalScore($neighbor->getScore()+$neighbor->getGuessedScore()); |
|
84 | 84 | if (!$visited) { |
85 | 85 | $heap->insert($neighbor); |
86 | 86 | } |