-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
Let AI engulf even if running out of atp #5729
Let AI engulf even if running out of atp #5729
Conversation
This is for the AI, right? That's unclear from just the title (so I had to open up this PR immediately when I received the notification to make sure this wasn't a fix for a critical regression in the game). |
Yes it is, sorry for not being clear |
From testing this today, the AI still doesn't engulf while out of ATP. |
It should work now, the "if statement" was built improperly |
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'm not seeing any references to EnterEngulfModeForcedState
so how does this actually force the engulf mode?
Well, tried rebasing onto master but it seems to mess up my branch again |
Probably easiest if you just start a new fresh local branch and either cherry-pick the commits you want from here or just redo the changes manually. Then delete your local branch named Edit: also I wanted to mention that usually when duplicate commits get created like that you've either messed up a merge (with losing the info that the branch is actually merged) or an interactive rebase ended up rebasing remote commits (this is pretty easy to accidentally do if you do an interactive rebase onto a different branch and you have merge commits made in your branch, it's better to either rebase or squash first). |
1d8f921
to
fecacc8
Compare
We are currently in feature freeze until the next release. |
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 have noticed some issues with the code, but the main functionality seems to work based on my testing
How? I'm sorry that I'm commenting while on my break but I've read this PR like twice but I didn't see anything that could set the forced engulfing time variable above 0? So that means that there should be no way for this PR to trigger that functionality (refer to my comment: #5729 (review)) |
control.SetStateColonyAware(entity, engulf ? MicrobeState.Engulf : MicrobeState.Normal); | ||
var ourCompounds = compoundStorage.Compounds; | ||
|
||
if (atpLevel <= Constants.ENGULF_NO_ATP_TRIGGER_THRESHOLD) |
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 see the EnterEngulfModeForcedState
call now, but now I'm wondering why the ATP level is checked here? Because EnterEngulfModeForcedState
ultimately calls ForceStateApplyIfRequired
which only causes problems if ATP is not sufficient, so the AI code doesn't actually need this duplicate check, right?
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.
So we just use EnterEngulfModeForcedState
withour SetStateColonyAware
?
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.
Yes, I didn't fully read the PR again but from a quick look EnterEngulfModeForcedState
already has colony handling and checking for the ATP levels. So my comment is just about reducing unnecessary code in the AI system in this spot.
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.
There's just a small change I'd like to see to make this conform to our styleguide. Then if the AI works fine in game this will be ready to merge.
bool isHunting = CheckForHuntingConditions(ref ai, ref position, ref organelles, ref ourSpecies, ref engulfer, | ||
ref cellProperties, ref control, ref health, ref compoundStorage, entity, speciesFocus, speciesAggression, | ||
speciesActivity, speciesOpportunism, strain, random, false, atpLevel); | ||
if (isHunting) |
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.
Wouldn't it be cleaner to not split out the isHunting
variable here? There's already a very similar block of code above that doesn't use a temporary variable. (will also need to add braces here as the if is then so long)
{ | ||
// Keep the maximum at 95% full, as there is flickering when near full | ||
ai.ATPThreshold = 0.95f * speciesFocus / Constants.MAX_SPECIES_FOCUS; | ||
} | ||
|
||
// Even if we are out of ATP and there is microbe nearby, engulf them. | ||
// make sure engulfing doesn't kill the cell. The cell won't engulf if it would kill it |
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 think this comment line is pretty unclear and either should be removed or reworded.
Other than that one hard to read comment, the code changes look good to me here. And as long as the AI does actually sometimes use this new functionality, this will be good to merge. |
comment fix
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'll trust that there's been enough playtesting to merge this.
Brief Description of What This PR Does
If there is a microbe nearby and the cell is not moving make it able to engulf the prey in order to survive
Related Issues
closes #5678
Progress Checklist
Note: before starting this checklist the PR should be marked as non-draft.
break existing features:
https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
(this is important as to not waste the time of Thrive team
members reviewing this PR)
styleguide.
Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.