-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathFinding.php
More file actions
27 lines (24 loc) · 1.09 KB
/
PathFinding.php
File metadata and controls
27 lines (24 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
// класс для поиска пути Astar
abstract class PathFinding
{
private static AStar $_astar; // поиск пути
private static DomainLogic $_logic;
// алгоритм поиска пути A*
final static public function astar(string $from, string $to): array
{
// кеширование не актуально nr карта может меняться
// todo предусмотреть возможность в tettain блокирвоать клетк (например станвоитя на клетку) и не давать пройти или выталкивать с нее
if(empty(static::$_astar))
{
static::$_logic = new DomainLogic();
static::$_astar = new AStar(static::$_logic);
}
if($return = static::$_astar->run($from, $to))
{
// удалим точку на которой стоим
array_shift($return);
}
return $return;
}
}