058b725ca9ca16308e004dc4c9506936dfc48537
The AI uses HarvesterBotModule to check for idle harvesters, and give them harvest orders. By default it scans every 50 ticks (2 seconds at normal speed), and for any idle harvesters locates an ore patch and issues a harvest order. This FindNextResource to scan for a suitable ore path is quite expensive. If the AI has to scan for ore patches for several harvesters, then this can produce a noticeable lag spike. Additionally, when there are no available ore patches, the scan will just keep repeating since the harvesters will always be idle - thus the lag spikes repeat every 50 ticks. To reduce the impact, there already exists a randomization on the first scan interval so that multiple different AIs scan on different ticks. By ensuring the AI players scan at different times, we avoid a huge lag spike where they all operate on the same tick. To reduce the impact even more, we make four additional changes: - Scans continue to be done every 50 ticks to detect harvesters. But we spread out the searches for ore patches over multiple later ticks. We'll only perform one ore patch search per tick. This means instead of ordering e.g. 30 harvesters on a single tick and creating a spike, we order one on each tick over the next 30 ticks instead. This spreads out the performance impact. - When a harvester fails to locate any suitable ore patch, we put it on a longer cooldown, by default 5x the regular cooldown. We don't need to scan as often for these harvesters, since it'll take time for new resources to appear. - We change the path search in FindNextResource from FindPathToTargetCellByPredicate to FindPathToTargetCells. The format in an undirected path search that must flood fill from the start location. If ore is on the other side of the map, this entails searching the whole map which is very expensive. By maintaining a lookup of resource types per cell, we can instead give the target locations directly to the path search. This lookup requires a small overhead to maintain, but allows for a far more efficient path search to be carried out. The search can be directed towards the target locations, and the hierarchical path finder can be employed resulting in a path search that explores far fewer cells. A few tweaks are made to ResourceClaimLayer to avoid it creating empty list entries when this can be avoided. - We adjust how the enemy avoidance cost is done. Previously, this search used world.FindActorsInCircle to check for nearby enemies, but this check was done for every cell that was searched, and is itself quite expensive. Now, we create a series of "bins" and cache the additional cost for that bin. This is a less fine grained approach but is sufficient for our intended goal of "avoid resource patches with too many enemies nearby". The customCost function is now less expensive so we can reuse the avoidance cost stored for each bin, rather than calculating fresh for every cell.
OpenRA
A Libre/Free Real Time Strategy game engine supporting early Westwood classics.
- Website: https://www.openra.net
- Chat: #openra on Libera (web) or Discord

- Repository: https://github.com/OpenRA/OpenRA
Please read the FAQ in our Wiki and report problems at https://github.com/OpenRA/OpenRA/issues.
Join the Forum for discussion.
Play
Distributed mods include a reimagining of
- Command & Conquer: Red Alert
- Command & Conquer: Tiberian Dawn
- Dune 2000
EA has not endorsed and does not support this product.
Check our Playing the Game Guide to win multiplayer matches.
Contribute
- Please read INSTALL.md and Compiling on how to set up an OpenRA development environment.
- See Hacking for a (now very outdated) overview of the engine.
- Read and follow our Code of Conduct.
- To get your patches merged, please adhere to the Contributing guidelines.
Mapping
- We offer a Mapping Tutorial as you can change gameplay drastically with custom rules.
- For scripted mission have a look at the Lua API.
- If you want to share your maps with the community, upload them at the OpenRA Resource Center.
Modding
- Download a copy of the OpenRA Mod SDK to start your own mod.
- Check the Modding Guide to create your own classic RTS.
- There exists an auto-generated Trait documentation to get started with yaml files.
- Some hints on how to create new OpenRA compatible Pixelart.
- Upload total conversions at our Mod DB profile.
Support
- Sponsor a mirror server if you have some bandwidth to spare.
- You can immediately set up a Dedicated Game Server.
License
Copyright (c) OpenRA Developers and Contributors This file is part of OpenRA, which is free software. It is made available to you under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. For more information, see COPYING.
Description
Languages
C#
79.3%
Lua
16%
Fluent
3.1%
Shell
0.6%
Objective-C
0.2%
Other
0.5%