Commit Graph

41 Commits

Author SHA1 Message Date
dnqbob
5d2f2bdd1d Add TraitLocation to all bot modules. 2023-09-11 14:33:32 +03:00
RoosterDragon
f4af5c1764 Fix CA1852 2023-06-06 11:51:47 +03:00
RoosterDragon
8a285f9b19 Fix IDE0090 2023-04-08 16:51:51 +03:00
RoosterDragon
164abfdae1 Fix IDE0083 2023-04-08 16:51:51 +03:00
RoosterDragon
d4135d608e Fix IDE0039 2023-02-27 10:09:11 +01:00
abcdefg30
5bf7fe852c Remove the copyright year numbers 2023-01-11 11:58:54 +02:00
dnqbob
6fbdc2c221 HarvesterBotModule should not command harvesters that cannot be ordered 2022-11-24 23:09:22 +01:00
abcdefg30
d8349a429a Remove unnecessary uses of Exts.IsTraitEnabled 2022-10-14 13:50:57 +03:00
RoosterDragon
5a8f91aa21 Add a hierarchical path finder to improve pathfinding performance.
Replaces the existing bi-directional search between points used by the pathfinder with a guided hierarchical search. The old search was a standard A* search with a heuristic of advancing in straight line towards the target. This heuristic performs well if a mostly direct path to the target exists, it performs poorly it the path has to navigate around blockages in the terrain. The hierarchical path finder maintains a simplified, abstract graph. When a path search is performed it uses this abstract graph to inform the heuristic. Instead of moving blindly towards the target, it will instead steer around major obstacles, almost as if it had been provided a map which ensures it can move in roughly the right direction. This allows it to explore less of the area overall, improving performance.

When a path needs to steer around terrain on the map, the hierarchical path finder is able to greatly improve on the previous performance. When a path is able to proceed in a straight line, no performance benefit will be seen. If the path needs to steer around actors on the map instead of terrain (e.g. trees, buildings, units) then the same poor pathfinding performance as before will be observed.
2022-08-03 23:12:42 +02:00
abcdefg30
6a31b1f9f3 Update the copyright header year 2022-05-28 00:35:10 -05:00
Eduardo Cáceres
79f321cb44 .Any(), .Count() -> .Count or .Length 2022-05-18 11:42:36 -05:00
RoosterDragon
d2935672ca Fix the shape of the IPathFinder interface, ensure all path searches use it.
Some path searches, using PathSearch, were created directly at the callsite rather than using the pathfinder trait. This means some searches did not not benefit from the performance checks done in the pathfinder trait. It also means the pathfinder trait was not responsible for all pathing done in the game. Fix this with the following changes:
- Create a sensible shape for the IPathFinder interface and promote it to a trait interface, allowing theoretical replacements of the implementation. Ensure none of the concrete classes in OpenRA.Mods.Common.Pathfinder are exposed in the interface to ensure this is possible.
- Update the PathFinder class to implement the interface, and update several callsites manually running pathfinding code to instead call the IPathFinder interface.
- Overall, this allows any implementation of the IPathFinder interface to intercept and control all path searching performed by the game. Previously some searches would not have used it, and no alternate implementations were possible as the existing implementation was hardcoded into the interface shape.

Additionally:
- Move the responsibility of finding paths on completed path searches from pathfinder to path search, which is a more sensible location.
- Clean up the pathfinder pre-search optimizations.
2022-04-18 11:18:43 +01:00
Matthias Mailänder
0e7ad43425 Remove unused parameters. 2022-04-01 23:30:26 +02:00
RoosterDragon
2ab3917f29 Clean up usage of DomainIndex
- When a path search is being performed the path search will not attempt route to inaccessible cells, so domain index checks to avoid inaccessible cells in the search predicate are redundant and can be removed.
- DomainIndex is a required world trait, so we don't need to use TraitOrDefault and therefore can avoid dealing with the null case.
2022-01-30 16:22:26 +01:00
RoosterDragon
6dc189b7d1 Rearrange various API surfaces related to pathfinding.
The existing APIs surfaces for pathfinding are in a wonky shape. We rearrange various responsibilities to better locations and simplify some abstractions that aren't providing value.

- IPathSearch, BasePathSearch and PathSearch are combined into only PathSearch. Its role is now to run a search space over a graph, maintaining the open queue and evaluating the provided heuristic function. The builder-like methods (WithHeuristic, Reverse, FromPoint, etc) are removed in favour of optional parameters in static creation methods. This removes confusion between the builder-aspect and the search function itself. It also becomes responsible for applying the heuristic weight to the heuristic. This fixes an issue where an externally provided heuristic ignored the weighting adjustment, as previously the weight was baked into the default heuristic only.
- Reduce the IGraph interface to the concepts of nodes and edges. Make it non-generic as it is specifically for pathfinding, and rename to IPathGraph accordingly. This is sufficient for a PathSearch to perform a search over any given IGraph. The various customization options are concrete properties of PathGraph only.
- PathFinder does not need to deal with disposal of the search/graph, that is the caller's responsibility.
- Remove CustomBlock from PathGraph as it was unused.
- Remove FindUnitPathToRange as it was unused.
- Use PathFinder.NoPath as the single helper to represent no/empty paths.
2022-01-30 11:47:52 +01:00
Andre Mohren
6810469634 Updated copyright years. 2021-06-29 18:33:21 -05:00
teinarss
10676be377 Replace F extension with string interpolation 2021-05-08 22:20:59 +02:00
teinarss
d60c05eff3 Change to use pattern matching 2021-03-27 17:29:20 +01:00
Paul Chote
dcd8eccee4 Replace ResourceLayer references with IResourceLayer in traits/warheads. 2021-03-20 16:45:41 +01:00
reaperrr
1a7a47fa08 Randomize AI idle harvester scan intervals 2021-02-28 18:58:03 +01:00
abcdefg30
10f645bf77 Replace usage of the Stances dict by a method call 2020-11-14 11:04:41 +00:00
abcdefg30
eda9966d27 Rename Stance to PlayerRelationship 2020-11-14 11:04:41 +00:00
Paul Chote
5a7dc385a3 Remove obsolete LocomotorInfo caching. 2020-10-18 18:19:56 +02:00
abcdefg30
27d0465891 Remove workarounds for querying the PlayerActor in Created 2020-05-30 19:47:29 +02:00
abcdefg30
23b3c237b7 Update the year numbers in all license headers to 2020 2020-01-05 17:00:34 +00:00
matjaeck
5ac9d2c2f1 Fix botmodules querying the Player actor before it is assigned. 2019-12-05 01:48:56 +01:00
tovl
4a609bbee8 Allow units to give way when path is blocked by oncoming unit. 2019-09-15 17:51:34 +01:00
Paul Chote
815ea1e13b Make LastSearchFailed local to FindAndDeliverResources. 2019-08-25 17:20:38 +02:00
tovl
8690a4a6ce CLean up type check in harvesterbotmodule. 2019-08-10 19:12:50 +01:00
tovl
1b4ab564fe Fix AI harvester not resuming after chronoshift. 2019-08-10 19:12:50 +01:00
teinarss
2ddf9fa826 Using Locomotor instead of Info for pathfinding 2019-07-26 15:54:22 +02:00
tovl
ea4f24d0b7 Rework harvester automation. 2019-04-04 19:22:25 +02:00
Paul Chote
c7d9d9613e Remove Order.TargetLocation from Harvester. 2019-03-04 18:08:42 +00:00
Paul Chote
fd013ad9d0 Remove unnecessary trait queries from HarvesterBotModule 2019-02-03 15:54:07 +01:00
abcdefg30
cadbd0d9ab Change the year number in all cs headers from 2018 to 2019 2019-01-26 23:15:21 +01:00
reaperrr
137d3be346 Add plumbing for bots auto-replacing harvesters
If their number drops below refinery count.
2019-01-06 08:39:45 +01:00
reaperrr
e36ef57e35 Increase default scan interval for idle bot harvesters
Every 2 seconds (at default speed) should be enough.
2019-01-06 08:39:45 +01:00
reaperrr
54c2894b4e Split off last bot modules
And dissolve AI namespace.
There would have been so little left in Common.AI,
that keeping it made no sense anymore.
2018-12-31 10:56:01 +00:00
reaperrr
67cba65800 Fix bot module plumbing
Fixes the issues pointed out after the original harvester module was merged.
Also merges the update rules as discussed on IRC.
2018-11-24 11:05:37 +00:00
Andre Mohren
b1a44086a0 Removed unused using directives. 2018-11-17 17:23:22 +00:00
reaperrr
927b6cd561 Convert AIHarvesterManager into *Module 2018-11-04 01:11:00 +01:00