Commit Graph

26 Commits

Author SHA1 Message Date
reaperrr
08aaa998aa Fix AI BuildingLimits
The AI BaseBuilder would allow building a structure not only when the current number was lower, but also of it was equal to the limit, which allowed the AI to build one too much of every building.
2017-09-15 19:31:57 +01:00
Taryn Hill
43317e0f5d Update copyright notice year to 2017 2016-12-31 23:46:13 -06:00
Paul Chote
23f4ae5027 Replace UpgradeMinEnabledLevel checks with an EnabledByDefault shim. 2016-11-19 17:19:25 +00:00
Paul Chote
e71225496b Clarify GPL version. 2016-02-21 16:30:48 +00:00
Paul Chote
b396965fd9 Update licence header year. 2016-02-21 16:27:31 +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
atlimit8
b6f17df260 Add ActorsHavingTrait<TTrait>([Func<TTrait, bool]) 2015-10-28 16:36:45 -05: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
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
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
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
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
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
reaperrr
27ffd4967a AI base builder power tweaks 2015-07-07 22:22:59 +02:00
RoosterDragon
1515ac54f6 Enforce a line length limit. 2015-03-19 17:20:34 +00:00
penev92
6c6a4322ed Move the AI namespace to Mods.Common 2015-02-09 16:57:29 +02:00