-
Notifications
You must be signed in to change notification settings - Fork 6
/
manager_mediator.py
2423 lines (1897 loc) · 62.4 KB
/
manager_mediator.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Enable cross manager communication.
"""
from abc import ABCMeta, abstractmethod
from typing import (
TYPE_CHECKING,
Any,
Callable,
DefaultDict,
Dict,
List,
Optional,
Set,
Tuple,
Union,
)
import numpy as np
from map_analyzer import MapData
from sc2.game_info import Ramp
from sc2.ids.unit_typeid import UnitTypeId as UnitID
from sc2.position import Point2
from sc2.unit import Unit
from sc2.units import Units
from scipy.spatial import KDTree
from ares.consts import EngagementResult, ManagerName, ManagerRequestType, UnitRole
if TYPE_CHECKING:
from ares.managers.squad_manager import UnitSquad
class IManagerMediator(metaclass=ABCMeta):
"""
The Mediator interface declares a method used by components to notify the
mediator about various events. The Mediator may react to these events and
pass the execution to other components (managers).
"""
# each manager has a dict linking the request type to a callable action
manager_requests_dict: Dict[ManagerRequestType, Callable]
@abstractmethod
def manager_request(
self,
receiver: ManagerName,
request: ManagerRequestType,
reason: str = None,
**kwargs
) -> Any:
"""How requests will be structured.
Parameters
----------
receiver :
The Manager the request is being sent to.
request :
The Manager that made the request
reason :
Why the Manager has made the request
kwargs :
If the ManagerRequest is calling a function, that function's keyword
arguments go here.
Returns
-------
Any
"""
pass
class ManagerMediator(IManagerMediator):
"""
Mediator concrete class is the single source of truth and coordinator of
communications between the managers.
"""
def __init__(self) -> None:
self.managers: Dict[str, "Manager"] = {} # noqa
def add_managers(self, managers: List["Manager"]) -> None: # noqa
"""Generate manager dictionary.
Parameters
----------
managers :
List of all Managers capable of handling ManagerRequests.
Returns
----------
None
"""
for manager in managers:
self.managers[str(type(manager).__name__)] = manager
def manager_request(
self,
receiver: ManagerName,
request: ManagerRequestType,
reason: str = None,
**kwargs
) -> Any:
"""Function to request information from a manager.
Parameters
----------
receiver :
Manager receiving the request.
request :
Requested attribute/function call.
reason :
Why the request is being made.
kwargs :
Keyword arguments (if any) to be passed to the requested function.
Returns
-------
Any :
There are too many possible return types to list all of them.
"""
return self.managers[receiver.value].manager_request(
receiver, request, reason, **kwargs
)
"""
Add methods and properties below for commonly used manager requests or for
readability in other classes
Format: properties in alphabetical order followed by methods in alphabetical order
Basically, this can act as an API front end for accessing the managers
Or eventually requesting the managers calculate something (like a new attack target)
`manager_request` can also be used
"""
"""
AbilityTrackerManager
"""
@property
def get_unit_to_ability_dict(self) -> dict[int, Any]:
"""Get a dictionary containing unit tag, to ability frame cooldowns.
AbilityTrackerManager.
Returns
-------
Dict[int, Any] :
Unit tag to abilities and the next frame they can be casted.
"""
return self.manager_request(
ManagerName.ABILITY_TRACKER_MANAGER,
ManagerRequestType.GET_UNIT_TO_ABILITY_DICT,
)
def update_unit_to_ability_dict(self, **kwargs):
"""Update tracking to reflect ability usage.
After a unit uses an ability it should call this to update the frame the
ability will next be available
AbilityTrackerManager.
Parameters
----------
ability : AbilityId
The AbilityId that was used.
unit_tag : int
The tag of the Unit that used the ability
Returns
----------
None
"""
return self.manager_request(
ManagerName.ABILITY_TRACKER_MANAGER,
ManagerRequestType.UPDATE_UNIT_TO_ABILITY_DICT,
**kwargs,
)
"""
BuildingManager
"""
def build_with_specific_worker(self, **kwargs) -> bool:
"""Build a structure with a specific worker.
BuildingManager.
Parameters
-----
worker : Unit
The chosen worker.
structure_type : UnitID
What type of structure to build.
pos : Point2
Where the structure should be placed.
building_purpose : BuildingPurpose
Why the structure is being placed.
Returns
-------
bool :
True if a position for the building is found and the worker is valid,
otherwise False
"""
return self.manager_request(
ManagerName.BUILDING_MANAGER,
ManagerRequestType.BUILD_WITH_SPECIFIC_WORKER,
**kwargs,
)
def cancel_structure(self, **kwargs) -> None:
"""Cancel a structure and remove from internal ares bookkeeping.
If you try cancelling without calling this method, ares may try
to keep rebuilding the cancelled structure.
BuildingManager.
Parameters
----------
structure : Unit
The actual structure to cancel.
Returns
----------
None
"""
return self.manager_request(
ManagerName.BUILDING_MANAGER,
ManagerRequestType.CANCEL_STRUCTURE,
**kwargs,
)
@property
def get_building_counter(self) -> DefaultDict[UnitID, int]:
"""Get a dictionary containing the number of each type of building in progress.
BuildingManager.
Returns
-------
DefaultDict[UnitID, int] :
Number of each type of UnitID presently being tracking for building.
"""
return self.manager_request(
ManagerName.BUILDING_MANAGER, ManagerRequestType.GET_BUILDING_COUNTER
)
@property
def get_building_tracker_dict(
self,
) -> Dict[int, Dict[str, Union[Point2, Unit, UnitID, float]]]:
"""Get the building tracker dictionary.
Building Manager.
Returns
-------
Dict[int, Dict[str, Union[Point2, Unit, UnitID, float]]] :
Tracks the worker tag to:
UnitID of the building to be built
Point2 of where the building is to be placed
In-game time when the order started
Why the building is being built
"""
return self.manager_request(
ManagerName.BUILDING_MANAGER, ManagerRequestType.GET_BUILDING_TRACKER_DICT
)
"""
CombatSimManager
"""
def can_win_fight(self, **kwargs) -> EngagementResult:
"""Get the predicted engagement result between two forces.
Combat Sim Manager.
Parameters
----------
own_units : Units
Our units involved in the battle.
enemy_units : Units
The enemy units.
timing_adjust : bool
Take distance between units into account.
good_positioning : bool
Assume units are decently split.
workers_do_no_damage : bool
Don't take workers into account.
Returns
-------
EngagementResult :
Enum with human-readable engagement result
"""
return self.manager_request(
ManagerName.COMBAT_SIM_MANAGER, ManagerRequestType.CAN_WIN_FIGHT, **kwargs
)
"""
EnemyToBaseManager
"""
@property
def get_flying_enemy_near_bases(self) -> dict[int, set[int]]:
"""Get dictionary containing flying enemy near townhalls.
EnemyToBase Manager
Returns
-------
dict[int, set[int]] :
A dictionary where the integer key is a townhall tag.
And the value contains a set of ints cotianing enemy tags
near this base.
"""
return self.manager_request(
ManagerName.ENEMY_TO_BASE_MANAGER,
ManagerRequestType.GET_FLYING_ENEMY_NEAR_BASES,
)
@property
def get_ground_enemy_near_bases(self, **kwargs) -> dict[int, set[int]]:
"""Get dictionary containing ground enemy near townhalls.
EnemyToBase Manager
Returns
-------
dict[int, set[int]] :
A dictionary where the integer key is a townhall tag.
And the value contains a set of ints cotianing enemy tags
near this base.
"""
return self.manager_request(
ManagerName.ENEMY_TO_BASE_MANAGER,
ManagerRequestType.GET_GROUND_ENEMY_NEAR_BASES,
**kwargs,
)
@property
def get_main_air_threats_near_townhall(self) -> Units:
"""Get the main enemy air force near one of our bases.
EnemyToBase Manager
Returns
-------
Units :
The largest enemy air force near our bases.
"""
return self.manager_request(
ManagerName.ENEMY_TO_BASE_MANAGER,
ManagerRequestType.GET_MAIN_AIR_THREATS_NEAR_TOWNHALL,
)
@property
def get_main_ground_threats_near_townhall(self) -> Units:
"""Get the main enemy ground force near one of our bases.
EnemyToBase Manager
Returns
-------
Units :
The largest enemy ground force near our bases.
"""
return self.manager_request(
ManagerName.ENEMY_TO_BASE_MANAGER,
ManagerRequestType.GET_MAIN_GROUND_THREATS_NEAR_TOWNHALL,
)
@property
def get_th_tag_with_largest_ground_threat(self) -> int:
"""Get the tag of our townhall with the largest enemy ground force nearby.
WARNING: This will remember the townhall tag even if enemy has gone.
Do not use this to detect enemy at a base.
Use `get_main_ground_threats_near_townhall`
Or `get_ground_enemy_near_bases` instead
EnemyToBase Manager
Returns
-------
Units :
The largest enemy ground force near our bases.
"""
return self.manager_request(
ManagerName.ENEMY_TO_BASE_MANAGER,
ManagerRequestType.GET_TH_TAG_WITH_LARGEST_GROUND_THREAT,
)
"""
IntelManager
"""
@property
def get_enemy_expanded(self) -> bool:
"""Has the enemy expanded?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_EXPANDED
)
@property
def get_enemy_four_gate(self) -> bool:
"""Has the enemy gone four gate?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_FOUR_GATE
)
@property
def get_enemy_has_base_outside_natural(self) -> bool:
"""Has the enemy expanded outside of their natural?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER,
ManagerRequestType.GET_ENEMY_HAS_BASE_OUTSIDE_NATURAL,
)
@property
def get_enemy_ling_rushed(self) -> bool:
"""Has the enemy ling rushed?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_LING_RUSHED
)
@property
def get_enemy_marine_rush(self) -> bool:
"""Is the enemy currently marine rushing?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_MARINE_RUSH
)
@property
def get_enemy_marauder_rush(self) -> bool:
"""Is the enemy currently marauder rushing?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_MARAUDER_RUSH
)
@property
def get_enemy_ravager_rush(self) -> Point2:
"""Has the enemy ravager rushed?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_RAVAGER_RUSH
)
@property
def get_enemy_roach_rushed(self) -> Point2:
"""Did the enemy roach rush?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_ROACH_RUSHED
)
@property
def get_enemy_was_greedy(self) -> Point2:
"""Was the enemy greedy?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_WAS_GREEDY
)
@property
def get_enemy_went_four_gate(self) -> Point2:
"""The enemy went four gate this game?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_WENT_FOUR_GATE
)
@property
def get_enemy_went_marine_rush(self) -> Point2:
"""The enemy went marine rush this game?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_WENT_MARINE_RUSH
)
@property
def get_enemy_went_marauder_rush(self) -> Point2:
"""The enemy went marauder rush this game?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_WENT_MARAUDER_RUSH
)
@property
def get_enemy_went_reaper(self) -> Point2:
"""The enemy opened with reaper this game?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_WENT_REAPER
)
@property
def get_enemy_worker_rushed(self) -> Point2:
"""The enemy went for a worker rush this game?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_ENEMY_WORKER_RUSHED
)
@property
def get_is_proxy_zealot(self) -> bool:
"""There is currently proxy zealot attempt from enemy?
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns
-------
bool
"""
return self.manager_request(
ManagerName.INTEL_MANAGER, ManagerRequestType.GET_IS_PROXY_ZEALOT
)
"""
FlyingStructureManager
"""
@property
def get_flying_structure_tracker(self) -> dict[int, Any]:
"""Get the current information stored by FlyingStructureManager.
FlyingStructureManager
Returns
-------
dict[int, Any] :
Key -> structure_tag, Value -> Information about the flight.
"""
return self.manager_request(
ManagerName.FLYING_STRUCTURE_MANAGER,
ManagerRequestType.GET_FLYING_STRUCTURE_TRACKER,
)
def move_structure(self, **kwargs) -> None:
"""Request a structure to move via flight.
FlyingStructureManager
Parameters
----------
structure : Unit
Our units involved in the battle.
target : Point2
The enemy units.
should_land : bool, optional
Take distance between units into account.
Returns
----------
None
"""
return self.manager_request(
ManagerName.FLYING_STRUCTURE_MANAGER,
ManagerRequestType.MOVE_STRUCTURE,
**kwargs,
)
"""
ResourceManager
"""
@property
def get_mineral_patch_to_list_of_workers(self) -> Dict[int, Set[int]]:
"""Get a dictionary containing mineral tag to worker tags
Resource Manager
Returns
-------
dict :
Dictionary where key is mineral tag, and value is workers assigned here.
"""
return self.manager_request(
ManagerName.RESOURCE_MANAGER,
ManagerRequestType.GET_MINERAL_PATCH_TO_LIST_OF_WORKERS,
)
@property
def get_worker_tag_to_townhall_tag(self) -> dict[int, int]:
"""Get a dictionary containing worker tag to townhall tag.
Where the townhall is the place where worker returns resources
Resource Manager
Returns
-------
dict :
Dictionary where key is worker tag, and value is townhall tag.
"""
return self.manager_request(
ManagerName.RESOURCE_MANAGER,
ManagerRequestType.GET_WORKER_TAG_TO_TOWNHALL_TAG,
)
@property
def get_worker_to_mineral_patch_dict(self) -> dict[int, int]:
"""Get a dictionary containing worker tag to mineral patch tag.
Resource Manager
Returns
-------
dict :
Dictionary where key is worker tag, and value is mineral tag.
"""
return self.manager_request(
ManagerName.RESOURCE_MANAGER,
ManagerRequestType.GET_WORKER_TO_MINERAL_PATCH_DICT,
)
def remove_mineral_field(self, **kwargs) -> None:
"""Request for a mineral field to be removed from bookkeeping.
Resource Manager
Parameters
-----
mineral_field_tag : int
The tag of the patch to remove.
Returns
----------
None
"""
return self.manager_request(
ManagerName.RESOURCE_MANAGER,
ManagerRequestType.REMOVE_MINERAL_FIELD,
**kwargs,
)
@property
def get_worker_to_vespene_dict(self) -> dict:
"""Get a dictionary containing worker tag to gas building tag.
Resource Manager
Returns
-------
dict :
Dictionary where key is worker tag, and value is gas building tag.
"""
return self.manager_request(
ManagerName.RESOURCE_MANAGER,
ManagerRequestType.GET_WORKER_TO_GAS_BUILDING_DICT,
)
def remove_gas_building(self, **kwargs) -> None:
"""Request for a gas building to be removed from bookkeeping.
Resource Manager
Parameters
-----
gas_building_tag : int
The tag of the gas building to remove.
Returns
----------
None
"""
return self.manager_request(
ManagerName.RESOURCE_MANAGER,
ManagerRequestType.REMOVE_GAS_BUILDING,
**kwargs,
)
"""
PathManager
"""
def find_closest_safe_spot(self, **kwargs) -> Point2:
"""Find the closest point with the lowest cost on a grid.
PathManager
Parameters
-----
from_pos : Point2
Where the search starts from.
grid : np.ndarray
The grid to find the low cost point on.
radius : float
How far away the safe point can be.
Returns
-------
Point2 :
The closest location with the lowest cost.
"""
return self.manager_request(
ManagerName.PATH_MANAGER, ManagerRequestType.GET_CLOSEST_SAFE_SPOT, **kwargs
)
def find_low_priority_path(self, **kwargs) -> List[Point2]:
"""Find several points in a path.
This way a unit can queue them up all at once for performance reasons.
i.e. running drones from a base or sending an overlord to a new position.
This does not return every point in the path. Instead, it returns points spread
along the path.
PathManager
Parameters
----------
start : Point2
Start point of the path.
target : Point2
Desired end point of the path.
grid : np.ndarray
The grid that should be used for pathing.
Returns
-------
List[Point2] :
List of points composing the path.
"""
return self.manager_request(
ManagerName.PATH_MANAGER,
ManagerRequestType.FIND_LOW_PRIORITY_PATH,
**kwargs,
)
def find_lowest_cost_points(self, **kwargs) -> List[Point2]:
"""Find the point(s) with the lowest cost within `radius` from `from_pos`.
PathManager
Parameters
----------
from_pos : Point2
Point to start the search from.
radius : float
How far away the returned points can be.
grid : np.ndarray
Which grid to query for lowest cost points.
Returns
-------
List[Point2] :
Points with the lowest cost on the grid.
"""
return self.manager_request(
ManagerName.PATH_MANAGER,
ManagerRequestType.FIND_LOWEST_COST_POINTS,
**kwargs,
)
def find_path_next_point(self, **kwargs) -> Point2:
"""Find the next point in a path.
Parameters
----------
start : Point2
Start point of the path.
target : Point2
Desired end point of the path.
grid : np.ndarray
The grid that should be used for pathing.
sensitivity : int, optional
Amount of points that should be skipped in the full path between tiles that
are returned.
smoothing : bool, optional
Optional path smoothing where nodes are removed if it's possible to jump
ahead some tiles in a straight line with a lower cost.
sense_danger : bool, optional
Check to see if there are any dangerous tiles near the starting point. If
this is True and there are no dangerous tiles near the starting point, the
pathing query is skipped and the target is returned.
danger_distance : float, optional
How far away from the start to look for danger.
danger_threshold : float, optional
Minimum value for a tile to be considered dangerous.
Returns
-------
Point2 :
The next point in the path from the start to the target which may be the
same as the target if it's safe.
"""
return self.manager_request(
ManagerName.PATH_MANAGER, ManagerRequestType.PATH_NEXT_POINT, **kwargs
)
def find_raw_path(self, **kwargs) -> List[Point2]:
"""Used for finding a full path, mostly for distance checks.
PathManager
Parameters
----------
start : Point2
Start point of the path.
target : Point2
Desired end point of the path.
grid : np.ndarray
The grid that should be used for pathing.
sensitivity : int
Amount of points that should be skipped in the full path between tiles that
are returned.
Returns
-------
List[Point2] :
List of points composing the path.
"""
return self.manager_request(
ManagerName.PATH_MANAGER, ManagerRequestType.FIND_RAW_PATH, **kwargs
)
@property
def get_air_avoidance_grid(self) -> np.ndarray:
"""Get the air avoidance pathing grid.
PathManager
Example:
```py
import numpy as np
avoidance_grid: np.ndarray = self.mediator.get_air_avoidance_grid
```