Commit Graph

48 Commits

Author SHA1 Message Date
atlimit8
09984683a7 Add ActorInfo.TraitInfo[OrDefault]<T>() requiring ITraitIfo types 2015-09-19 09:56:14 -05:00
atlimit8
6970959ef1 .Trait[OrDefault]<Trait> => .Info.Traits.Get[OrDefault]<TraitInfo> where applicable 2015-09-19 09:49:24 -05:00
atlimit8
8162fa27ab Add ActorInfo.HasTraitInfo<T>() requiring ITraitInfo types 2015-09-19 09:49:24 -05:00
atlimit8
85fab45451 Remove Actor.HasTrait<T>() 2015-09-19 09:49:23 -05:00
reaperrr
a580e6846e Merge pull request #9328 from Mailaender/ai-common-names
Fixed BuildingCommonNames magic
2015-09-13 18:53:37 +02:00
Matthias Mailänder
a7235d84e9 document the hidden keys 2015-09-13 08:30:17 +02:00
Matthias Mailänder
f903cfea96 don't throw as we are checking for null later 2015-09-12 10:27:22 +02:00
Matthias Mailänder
39b79f5347 don't load the AI routines in the map editor 2015-09-12 08:40:40 +02:00
reaperrr
4108b6da46 Merge pull request #9256 from Mailaender/ai-harv-search
Added AI search for new resource patches avoiding enemies
2015-09-11 23:25:59 +02:00
Matthias Mailänder
088f56d181 remove redundant bot debug message 2015-09-07 20:58:52 +02:00
reaperrr
60359cc6f5 Use HashSets for AI 2015-09-06 22:59:49 +02:00
Matthias Mailänder
0df8b3ba39 bring back AI search for new resource patches avoiding enemies 2015-09-06 12:56:23 +02:00
Matthias Mailänder
0e5fcc1756 Merge pull request #9279 from atlimit8/SemanticallySets
More HashSet trait fields & Lint support
2015-09-06 10:23:20 +02:00
atlimit8
8250f223c4 More HashSet trait fields & Lint support 2015-09-05 16:59:30 -05:00
atlimit8
dbae16b7a0 AI counts all aircraft rearm buildings 2015-09-04 10:45:58 -05:00
RoosterDragon
901e604cf3 Replace arrays with sets.
In places where arrays were being treated as a set, just create a set directly. This reveals the intention of such collections better, and also improves performance by allowing set based methods to be used.
2015-09-03 20:09:24 +01:00
atlimit8
f5c3575c5a Support multiple ITargetable traits 2015-09-02 23:14:40 -05:00
Zimmermann Gyula
0a79109d01 Implement HackyAI->UnitLimits. 2015-09-01 23:32:13 +02:00
Pavel Penev
256929073c Clean up some trait info loading code
Remove some methods that traits define to load their YAML values on their own.
2015-09-01 22:52:22 +03:00
RoosterDragon
d415d3ba4e Reduce allocations in the main game loop.
- Cache the shroud projection even for flat maps to avoid allocating single element arrays.
- Avoid LINQ in shroud and map projection queries to avoid enumerator allocations.
- Avoid LINQ in calculation of sync values.
- Cache enumerables in ProductionQueue.
- Cache delegate in HackyAI.
2015-08-18 21:17:28 +01:00
Oliver Brakmann
c539b9fcb4 Fix AI using SharedRandom values
The AI code runs on only one hosts, so by having the AI use SharedRandom values, the host's random gets out of sync with the other players' and crashes the game.
2015-08-01 15:59:12 +02:00
Oliver Brakmann
1b9367ae4b Fix potential NRE in AI BaseBuilder
Detected by Coverity
2015-07-29 14:53:15 +02:00
reaperrr
d8e458d028 Added TODOs for foundation of checked water cells
Fix description style issues
2015-07-28 22:03:53 +02:00
reaperrr
91178d6f62 Improved naval placement check
Moved water checks before --waitTicks.
Use Water enum instead of multiple booleans.
Check for BaseProvider rather than BaseBuilding.
Move expensive ClosEnoughToWater check to last position for naval
production override.
2015-07-28 22:03:52 +02:00
reaperrr
76f2145db2 Added random factor to building production delay
Early game AI usually follows the same build order (power plant first, then refinery), which also means they all start producing them at the same tick. This adds a random factor to the production delay, so not all AIs produce on the same tick.
2015-07-27 13:28:07 +02:00
reaperrr
c7af9c180e Further improved building placement failure check
Since naval structures have their own safety measures now and therefore shouldn't count towards failCount under normal circumstances, we can now assume that 3 consecutive placement failures mean lack of space. Therefore, rather than unconditionally resetting the failCount and retry every N ticks, we now cache the number of buildings and construction yards at the time of the 3rd consecutive failure and if the number of buildings hasn't decreased and number of construction yards not increased, we assume there is still not enough space and reset the retry delay instead.
2015-07-27 13:28:06 +02:00
reaperrr
65a6489ef1 Avoid consecutive attempts to build naval structures
If not enough water space can be found inside the base perimeter, stop the AI from trying to build naval production buildings permanently until it deploys another construction yard.

If enough water is available within the base perimeter, check whether any
building that provides buildable area (for adjacency) is close enough to
water, otherwise don't even start producing this naval structure.
2015-07-27 13:28:05 +02:00
reaperrr
0a5b812bb7 Check for consecutive failures to place a structure.
After 3 consecutive failed attempts, wait one minute before resetting the counter and trying again.
2015-07-27 13:21:58 +02:00
reaperrr
6ff394991d Fixed AI BaseBuilder low power check.
This was extremely borked:
The priority overrides for refinery, production and silo ignored power completely and never checked whether the structure might drive the AI into low power state; whereas the check for regular building checked whether the structure's power -exceeded- MinimumExcessPower (previously just 0). The catch is that power draw is represented by negative numbers, so the only buildings that would trigger this were - power plants.
Now it checks whether the sum of building power draw (negative) and AI's current power level are lower than MinimumExcessPower, if not, build the structure, if yes, build a power plant instead.
Additionally, this check is now performed for the early-game priority overrides as well.

Last but not least the AI would not(!) give power plants priority if it was already low on power. This has been fixed as well.
2015-07-27 13:06:18 +02:00
RoosterDragon
942ce6b5a6 Throttle the issuing of orders by the AI.
To prevent the AI generating lag spikes by issuing too many orders in a single tick, it is now limited in how many orders can be issued per tick. Extra orders are queued. This allows the performance hit of issuing multiple orders to be spread out over several ticks.
2015-07-26 12:57:19 +01:00
RoosterDragon
6b9dd9670a Avoid multiple AIs all issuing orders in exactly the same tick.
Randomize the initial tick used for each AI so they don't cause lag but all flooding the same tick with orders, but instead (try) and use a different tick for each AI. Order processing is expensive due to the need to sync world state, so it is best to spread out the performance cost of issuing these orders over different ticks.
2015-07-24 21:29:11 +01:00
Matthias Mailänder
413baf9d8b rename WDist.Range to WDist.Length 2015-07-09 10:55:38 +02:00
Matthias Mailänder
7447e0bf93 rename WRange to WDist 2015-07-09 10:55:38 +02:00
Matthias Mailänder
efe5ac26b9 Merge pull request #8679 from reaperrr/ai-tweaks1
Added configurable MinimumExcessPower to HackyAI
2015-07-07 23:48:48 +02:00
reaperrr
27ffd4967a AI base builder power tweaks 2015-07-07 22:22:59 +02:00
penev92
c3fcd9a8a1 Some cleanups 2015-07-06 22:24:50 +03:00
pevers
6ed0273656 Actors will lose targets and AI won't follow indefinitely 2015-06-28 19:11:53 +02:00
Oliver Brakmann
6650e3d9c7 Merge pull request #8319 from Mailaender/hacky-currentstate-nre
Fixed possible NREs in AI.StateMachine
2015-06-02 22:35:49 +02:00
Matthias Mailänder
cd5c0eca79 fix possible null reference exceptions 2015-06-02 22:16:16 +02:00
Oliver Brakmann
206c33ed41 Merge pull request #8226 from pchote/actor-disposal
Dispose traits when destroying an actor.
2015-06-02 19:33:22 +02:00
Matthias Mailänder
f171b23a1b move the null check up further to catch everything 2015-05-31 15:36:48 +02:00
Paul Chote
585a43fd8f Rename Actor.Destroy/Destroyed to Dispose/Disposed. 2015-05-29 19:08:38 +01:00
reaperrr
0d3dd28a3f Unharcode squad randomization, add minimum delay for creating attack force 2015-05-13 22:50:23 +02:00
RoosterDragon
ab2ef0ba03 Improve performance of target validation.
The Warhead and WeaponInfo classes now maintain preconstructed sets of valid and invalid targets to speed up validation checks since LINQ Intersect no longer has to be called (which recreates the sets internally each time).

Fixed minor bugs in the AI where it was repeating the validation logic but failing to account for invalid targets.
2015-04-02 21:11:12 +01:00
reaperrr
38d5163062 Refactors LimitedAmmo to AmmoPool.
Removes Reloads trait.

This enables adding multiple AmmoPools via @ differentiators and
Name which adds the possibility to assign each armament to a specific
ammo pool.

Furthermore, this moves all Reloads functionality onto AmmoPool.

Now a combination of all three is possible on a single actor: no limited
ammo, limited ammo that can reload on its own, and limited ammo which
needs to be reloaded at a rearm actor.

Additionally moves RearmSound from Minelayer to AmmoPool.
2015-03-26 23:21:01 +01:00
RoosterDragon
1515ac54f6 Enforce a line length limit. 2015-03-19 17:20:34 +00:00
Saulius Menkevičius
e1fa6af954 HackyAI can now build buildings with new MCV
There was an issue where HackyAI would try to build buildings
at old base location and would fail, unless it was placed at the
same place where the old MCV was.
2015-03-12 20:10:08 +02:00
penev92
6c6a4322ed Move the AI namespace to Mods.Common 2015-02-09 16:57:29 +02:00