-
-
Notifications
You must be signed in to change notification settings - Fork 595
Make AI use the signaling agent and add more conditions for responding to commands #6736
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
base: master
Are you sure you want to change the base?
Changes from 13 commits
224cb54
51c70e1
8d88abe
d5ed2a0
e491f3d
2d9a1c6
a45ef6b
144a74b
4d8bc43
e9f1932
8195e59
ecca883
36de1a4
f5fc4c8
07f62e2
08cbe44
c758755
0920682
74ac805
4c1708e
d471a74
43032a9
16a1d7e
b98eb16
880c09f
6340dba
ef56fc8
66cff35
8ae66c4
3426b61
01abd06
0301823
e1d3cc1
9179fa4
8d134db
9d5b1f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,6 +286,7 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor | |
| float speciesOpportunism = speciesBehaviour.Opportunism; | ||
|
|
||
| control.Sprinting = false; | ||
| control.Fleeing = false; | ||
|
|
||
| // If nothing is engulfing me right now, see if there's something that might want to hunt me | ||
| (Entity Entity, Vector3 Position, float EngulfSize)? predator = | ||
|
|
@@ -297,6 +298,8 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor | |
| if (control.State == MicrobeState.MucocystShield) | ||
| return; | ||
|
|
||
| control.Fleeing = true; | ||
|
|
||
| FleeFromPredators(ref position, ref ai, ref control, ref organelles, ref compoundStorage, entity, | ||
| predator.Value.Position, predator.Value.Entity, speciesFocus, | ||
| speciesActivity, speciesAggression, speciesFear, strain, random); | ||
|
|
@@ -377,6 +380,12 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor | |
| ai.ATPThreshold = 0.0f; | ||
| } | ||
|
|
||
| // Use signaling agent if I have any with a chance of 5% per think | ||
IdfbAn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
IdfbAn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (organelles.HasSignalingAgent && random.NextSingle() < Constants.AI_SIGNALING_CHANCE) | ||
| { | ||
| UseSignalingAgent(ref organelles, speciesAggression, ref signaling, ref control, random); | ||
|
||
| } | ||
|
|
||
| // Follow received commands if we have them | ||
| if (organelles.HasSignalingAgent && signaling.ReceivedCommand != MicrobeSignalCommand.None) | ||
| { | ||
|
|
@@ -525,6 +534,41 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor | |
| } | ||
| } | ||
|
|
||
| private void UseSignalingAgent(ref OrganelleContainer organelles, float speciesAggression, | ||
| ref CommandSignaler signaling, ref MicrobeControl control, Random random) | ||
| { | ||
| var willBeAggressiveThisTime = RollCheck(speciesAggression, Constants.MAX_SPECIES_AGGRESSION, random); | ||
|
||
|
|
||
| if (organelles.HasBindingAgent) | ||
| { | ||
| signaling.QueuedSignalingCommand = MicrobeSignalCommand.MoveToMe; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line seems useless so should be deleted (there's no early exit so we always execute the line Or alternatively it could be use some logic to detect when cells would be good to group together and would then set this but only if already in binding mode / going into binding mode, as otherwise it is useless to trigger this signal.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't it make more sense to remove the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well there has to be a some quite common condition to reset the signal as I don't want the AI to be entirely made so that it is assumed that there's almost always a signal. It is better for signals to only be sent occasionally so that the AI just doesn't become a total mess where it is always just forced to respond to other signals. Also for safety I think most "non-urgent" signals should not be activated if the current cell is receiving another signal as that just adds to the signal noise. |
||
| } | ||
|
|
||
| if (willBeAggressiveThisTime) | ||
| { | ||
| foreach (var organelle in organelles.Organelles!) | ||
| { | ||
| // Has pili or toxins | ||
| if (organelle.Definition.HasPilusComponent || organelles.AgentVacuoleCount > 0) | ||
| { | ||
| signaling.QueuedSignalingCommand = MicrobeSignalCommand.FollowMe; | ||
| break; | ||
| } | ||
|
|
||
| signaling.QueuedSignalingCommand = MicrobeSignalCommand.None; | ||
|
Comment on lines
+570
to
+594
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This loop looks very suspicious to me. I think instead what you actually want to do is first setup variables for pilus count, and then do a count of pili, and only then would you do the membersNearEnough calculation as that's an expensive calculation to do each loop iteration so I'm quite sure you didn't meant to put that logic inside this loop. |
||
| } | ||
| } | ||
| else if (!willBeAggressiveThisTime) | ||
| { | ||
| // TOOD | ||
| } | ||
|
|
||
| if (control.Fleeing) | ||
| { | ||
| signaling.QueuedSignalingCommand = MicrobeSignalCommand.FleeFromMe; | ||
| } | ||
| } | ||
|
|
||
| private bool CheckForHuntingConditions(ref MicrobeAI ai, ref WorldPosition position, | ||
| ref OrganelleContainer organelles, ref SpeciesMember ourSpecies, | ||
| ref Engulfer engulfer, ref CellProperties cellProperties, ref MicrobeControl control, ref Health health, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.