Commit Graph

72 Commits

Author SHA1 Message Date
RoosterDragon
8e89a6a696 Simplify names, remove unused usings, remove redundant casts. 2016-01-17 21:35:36 +00:00
Paul Chote
bee77db1e3 Rename variables for clarity. 2016-01-17 00:02:49 +00:00
Paul Chote
bec059a3c7 Remove unnecessary assumption about non-mobile. 2016-01-17 00:02:49 +00:00
Paul Chote
d4815407f2 Remove hardcoded trait assumptions from MCV and ConYards. 2016-01-17 00:02:49 +00:00
Paul Chote
e026a0f00f Create proper data structures for hardcoded AI classes. 2016-01-17 00:02:49 +00:00
Sean Hunt
8f4ec87b63 Factor silos needed warning to a new trait. 2015-12-27 14:40:37 -05:00
RoosterDragon
dcf375a412 Store Targetables in Actor.
This can be used to avoid several lookups for these traits, as well as allow Actor to provide specialised methods to deal with target types efficiently. This also reduces some code duplication.
2015-12-12 20:55:17 +00:00
Pavel Penev
c51bad6050 Expose HackyAI's Squads and IsEnabled fields 2015-12-07 01:41:16 +02:00
atlimit8
b6f17df260 Add ActorsHavingTrait<TTrait>([Func<TTrait, bool]) 2015-10-28 16:36:45 -05:00
atlimit8
7de98ad6d8 Merge pull request #9635 from RoosterDragon/occupy-space-perf
Speed up checks for IOccupySpace trait
2015-10-22 18:28:57 -05:00
RoosterDragon
a4338d9350 Remove a redundant check in FindAndDeployBackupMcv.
This avoids enumerating the mcvs twice.
2015-10-14 21:06:37 +01:00
RoosterDragon
262ab408b5 Speed up checks for IOccupySpace trait.
Eagerly load the trait (if it exists) in Actor, and use this reference to avoid having to perform self.Info.HasTraitInfo<IOccupySpaceInfo>() checks.
2015-10-14 20:46:15 +01:00
abcdefg30
b0c1f95ef2 Merge pull request #9486 from reaperrr/fix-9403
Fix AI queueing structure build orders twice at higher game speeds due to lag
2015-10-11 13:51:02 +02:00
reaperrr
3711ef8eb5 Fix AI queueing build orders twice at higher game speeds due to lag
Fixes #9403.
2015-10-11 01:53:25 +02:00
Paul Chote
8954ac585c Merge pull request #9442 from Mailaender/ai-world-check
Fixed AI bots trying to assign orders to units not in the world
2015-10-10 20:21:10 +01:00
Matthias Mailänder
4579e8af06 don't let the AI assign orders to units not in the world 2015-10-10 19:06:20 +02:00
atlimit8
a000bf7805 Merge pull request #9400 from reaperrr/fix-airefplaceperf
Fixed massive AI base builder performance issue
2015-10-02 23:18:10 -05:00
reaperrr
74308c245c Add AI MinBaseRadius to give more control over and slightly increase performance of AI building placement checks 2015-09-29 22:19:21 +02:00
reaperrr
2b0920398f Add AI MaxResourceCellsToCheck for refinery placement decision 2015-09-29 22:19:20 +02:00
Taryn Hill
3d7e49655d Fix NullReferenceException in HackyAI.BuildUnit
HackyAIInfo grew a UnitLimits Dictionary that was not null-checked.
Also null-check UnitsToBuild.
2015-09-28 13:17:19 -05:00
RoosterDragon
108f2e9b6e Tweak some AI methods to avoid allocations. 2015-09-26 21:12:07 +01:00
reaperrr
5ad9eb852c Fix massive AI base builder performance issue
Previously, the Refinery placement check would first collect all cells
with resources inside the MaxBaseRadius, then perform a full findPos check
for each cell until one of them would not return null. The problem was
that if all of the cells returned null (for example if there wasn't enough
space between base center and resource, or if all suitable space was
otherwise occupied), it would basically check all tiles with resources
only to fail finding a suitable position and fall back to the normal
findPos check.

Since nearbyResources already performs a shuffle, I simply made the check
use the first cell from the list and use the basic findPos fallback if
that cell is null.

Closes #4717.
2015-09-26 16:48:03 +02:00
atlimit8
9acf121eb1 Replace ActorInfo.Traits.WithInterface with ActorInfo.TraitInfos<T>() 2015-09-21 15:50:57 -05:00
atlimit8
131084d129 Changed missed ActorInfo.Traits.Contains => ActorInfo.HasTraitInfo 2015-09-19 12:06:37 -05:00
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