1 | <?php |
||
5 | abstract class Algorithm |
||
6 | { |
||
7 | private $openList; |
||
8 | private $closedList; |
||
9 | |||
10 | 19 | public function __construct() |
|
15 | |||
16 | /** |
||
17 | * @param Node $node |
||
18 | * @return Node[] |
||
19 | */ |
||
20 | abstract public function generateAdjacentNodes(Node $node); |
||
21 | |||
22 | /** |
||
23 | * @param Node $node |
||
24 | * @param Node $adjacent |
||
25 | * @return integer | float |
||
26 | */ |
||
27 | abstract public function calculateRealCost(Node $node, Node $adjacent); |
||
28 | |||
29 | /** |
||
30 | * @param Node $start |
||
31 | * @param Node $end |
||
32 | * @return integer | float |
||
33 | */ |
||
34 | abstract public function calculateEstimatedCost(Node $start, Node $end); |
||
35 | |||
36 | /** |
||
37 | * @return NodeList |
||
38 | */ |
||
39 | 15 | public function getOpenList() |
|
43 | |||
44 | /** |
||
45 | * @return NodeList |
||
46 | */ |
||
47 | 15 | public function getClosedList() |
|
51 | |||
52 | /** |
||
53 | * Sets the algorithm to its initial state |
||
54 | */ |
||
55 | 14 | public function clear() |
|
60 | |||
61 | /** |
||
62 | * @param Node $start |
||
63 | * @param Node $goal |
||
64 | * @return Node[] |
||
65 | */ |
||
66 | 13 | public function run(Node $start, Node $goal) |
|
116 | |||
117 | 11 | private function generatePathFromStartNodeTo(Node $node) |
|
131 | |||
132 | 11 | private function computeAdjacentNodes(Node $node, Node $goal) |
|
143 | } |
||
144 |