-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AI Squad workarounds #18900
AI Squad workarounds #18900
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me and a 10-AI game on Pool Party didn't show any noticable regressions, while also showing no noticable performance issues anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm otherwise.
mods/d2k/rules/ai.yaml
Outdated
@@ -219,7 +219,7 @@ Player: | |||
RequiresCondition: enable-omnius-ai | |||
SquadSize: 8 | |||
MaxBaseRadius: 40 | |||
ExcludeFromSquadsTypes: harvester, mcv | |||
ExcludeFromSquadsTypes: harvester, mcv, carryall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only fixes the issue for Omnius
, the other two are missing it.
7c96b69
to
ca00c49
Compare
Fixed. |
@@ -132,7 +132,7 @@ public SquadManagerBotModule(Actor self, SquadManagerBotModuleInfo info) | |||
// Use for proactive targeting. | |||
public bool IsPreferredEnemyUnit(Actor a) | |||
{ | |||
if (a == null || a.IsDead || Player.RelationshipWith(a.Owner) != PlayerRelationship.Enemy || a.Info.HasTraitInfo<HuskInfo>()) | |||
if (a == null || a.IsDead || Player.RelationshipWith(a.Owner) != PlayerRelationship.Enemy || a.Info.HasTraitInfo<HuskInfo>() || a.Info.HasTraitInfo<AircraftInfo>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is a little bit incompatible with some mods that has slow and hover aircraft. In doing so player's air unit will be ignored in air/ground squad target selection.
To solve d2k problem we should give the carryall a target type then ignore it in IgnoredEnemyTargetTypes
instead of hardcode it here.
|
||
// HACK: Drop back to the idle state if we haven't moved in 2.5 seconds | ||
// This works around the squad being stuck trying to attack-move to a location | ||
// that they cannot path to, generating expensive pathfinding calls each tick. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this idea cannot solve AI pathfinder spike lag on large map when AI use a large squad to AttackMove to a far away enemy base, which is the problem most mods have for AI.
lastUpdatedTick = owner.World.WorldTick; | ||
} | ||
|
||
// HACK: Drop back to the idle state if we haven't moved in 2.5 seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GroundAttackState make AI squad get into face to face confront towards enemy squad/base so there is high possibility that leader will attack from the same position for more than 2.5s, which is normal behavior.
Sorry for comments after merged, but I think at least the fix within the groundattackstate should be removed. |
We've run out of time to merge any more general AI improvements for the playtest, so this PR focuses on fixing a couple of specific high-impact issues with (hopefully) low risk workarounds.
The first commit essentially solves the AI performance cliff that happens when ground or naval forces squads a naval or ground unit that they cannot reach, and then spend the rest of their lives stuck trying to path to it, bringing performance to a crawl. Forcing the squad into the idle state if the leader hasn't moved for 2.5 seconds breaks this loop and restores normal performance. This has a side-effect of causing units that are stationary because they are shooting something to pick new targets, but this is often the same unit they were already shooting so I didn't notice any noticable regression in behaviour when spectating AI games. The RA map "Pool Party" with random bots is a good testcase to demonstrate this issue and workaround.
The second and third commits fix problems with carryalls in d2k: the AI would send carryalls loaded with their harvesters to circle over enemy bases, and combat units would get hung up on enemy carryalls and force games into an idle stalemate. Air units are typically in support roles, so this should hopefully have a similarly small impact in real-game behaviour in the other mods.