-
Notifications
You must be signed in to change notification settings - Fork 261
add guard against OnDefeat failures for AI #7256
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
Open
relent0r
wants to merge
5
commits into
FAForever:develop
Choose a base branch
from
relent0r:fix/disable-ai-platoon-guard
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7
−2
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ad2ab6
add guard against cases of platoon functions not being availble durin…
relent0r bb66e1c
add snippet
relent0r b1ad7c0
fix snippet typo as I can't spell
relent0r 6e3601d
typo that the bot caught (good bot)
relent0r d689d10
Update changelog/snippets/ai.7256.md
relent0r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Fix error when an army is defeated related to missing AI platoon functions (#7256). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I read a bit of the platoon code, and it seems like there's some manual
setmetatableuse that could be leaving platoons with an incomplete/wrong platoon class?For example,
AIPlatoonAdaptiveSilohas a typo usingAIPlatoonAdaptiveSiloBehaviorinstead ofAIPlatoonAdaptiveSilo, but it's not being used anywhere so nobody caught the issue.fa/lua/aibrains/platoons/platoon-adaptive-silo.lua
Line 249 in 4179780
Could you post the replay and maybe investigate the metatable of the platoon that fails at being destroyed (for example if it is a mod using the adaptive silo)? These functions should never be missing because they're part of the base class. Even if the platoon is from a mod.
Uh oh!
There was an error while loading. Please reload this page.
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 was based off a replay for my own AI.
https://replay.faforever.com/27584457
I don't disagree that it may have something to do with the state machine platoon implementation. The platoons in question were otherwise functioning fine.
I thought this would be the safest change to make that would be low risk of unforeseen consequences.
I did a dump of the platoon table when troubleshooting as I thought maybe I'd accidentally set it to an empty table, but the resulting dump looked the same as any other platoon and had the c object attached so I was thinking that the platoon was mid was through its own destruction.
In my testing I only had the issue happen once in say 10 games but a player pointed out that it happened alot more often for them with the difference being that they had a much higher player count.
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.
If you have suggestions of I could better troubleshoot it then I'm happy to try find the core reason.
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.
I did some metatable trickery in this branch to track down tracebacks of what changes were done to the platoon that failed:
https://github.com/FAForever/fa/tree/investigate-ai-ondefeat-failures
It's useful so I'll make a PR for it on a more organized branch.
I have included the output log in the branch files. What stands out to me is this final assignment of the failing platoon's metatable to
nil, which would cause it to not have the necessary commands.After investigating RNGAI, I saw:
Where
PerformBuildTaskis a State.But that State only exists in
lua\AI\StateMachines\platoon-engineer-utility.luaAIPlatoonEngineerBehaviorOur engineer is clearly using
lua\AI\StateMachines\platoon-engineer-resource.luaAIPlatoonEngineerBehavior,Despite having the same name, that file's class does not have
PerformBuildTaskand does not inherit from the utility engineer class.Therefore we change the unit to a
nilState, which loses theStopandPlatoonDisbandNoAssignmethods.ChangeStatehas no nil check, so yournildoes go directly into the metatable:fa/lua/system/class.lua
Lines 784 to 818 in 653be9b