Skip to content
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

Merged
merged 3 commits into from
Dec 7, 2020
Merged

AI Squad workarounds #18900

merged 3 commits into from
Dec 7, 2020

Conversation

pchote
Copy link
Member

@pchote pchote commented Dec 6, 2020

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.

@pchote pchote added this to the Next Release milestone Dec 6, 2020
reaperrr
reaperrr previously approved these changes Dec 7, 2020
Copy link
Contributor

@reaperrr reaperrr left a 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

Copy link
Member

@abcdefg30 abcdefg30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm otherwise.

@@ -219,7 +219,7 @@ Player:
RequiresCondition: enable-omnius-ai
SquadSize: 8
MaxBaseRadius: 40
ExcludeFromSquadsTypes: harvester, mcv
ExcludeFromSquadsTypes: harvester, mcv, carryall
Copy link
Member

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.

@pchote
Copy link
Member Author

pchote commented Dec 7, 2020

Fixed.

@abcdefg30 abcdefg30 merged commit 7c852d9 into OpenRA:bleed Dec 7, 2020
@abcdefg30
Copy link
Member

Changelog

@@ -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>())
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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.

@dnqbob
Copy link
Contributor

dnqbob commented Dec 16, 2020

Sorry for comments after merged, but I think at least the fix within the groundattackstate should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants