Skip to content

Make AI use the signaling agent and add more conditions for responding to commands#6736

Draft
IdfbAn wants to merge 34 commits intomasterfrom
5118_ai_signaling_agent
Draft

Make AI use the signaling agent and add more conditions for responding to commands#6736
IdfbAn wants to merge 34 commits intomasterfrom
5118_ai_signaling_agent

Conversation

@IdfbAn
Copy link
Member

@IdfbAn IdfbAn commented Feb 15, 2026

Brief Description of What This PR Does

This PR makes the microbe AI use the signaling agent and adds more conditions for responding to commands.

Related Issues

Closes #5118
Discussion: https://forum.revolutionarygamesstudio.com/t/how-should-ai-use-the-signaling-agent/1233

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

  • PR author has checked that this PR works as intended and doesn't
    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)
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    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.

// Use signaling agent if I have any with a chance of 5% per think
if (organelles.HasSignalingAgent && random.NextSingle() < Constants.AI_SIGNALING_CHANCE)
{
UseSignalingAgent(ref organelles, speciesAggression, ref signaling, ref control, random);
Copy link
Member

Choose a reason for hiding this comment

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

It seems like there's only one case where the signalling command is set to None. That means that cells do not stop signalling! That's a very, very major bug in my opinion because eventually I think most cells will just be signalling all the time.

Also I think another key part still missing is that cells should decide to ignore an incoming signalling command in certain situations (like if become aggressive signal is too far away, or a move signal is far away and the cell is not that full on resources).

Without those two things I think the signals will quite effectively destroy any useful AI behaviours as they'll get permanently locked into following the signal of the first species member of them that triggered it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have suggestions for when it should be set to no command?

Copy link
Member

Choose a reason for hiding this comment

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

I'd say whenever the original condition to set a signal is gone, or like after 15-30 seconds of the cell not feeling like it should send the same signal again. Something like that, but I'm sure someone else more familiar with the AI could come up with a more advanced codnitions.

Hopefully this is only a temporary workaround.
@hhyyrylainen hhyyrylainen changed the base branch from master to multicellular_processes February 18, 2026 09:38
@hhyyrylainen hhyyrylainen changed the base branch from multicellular_processes to master February 18, 2026 09:38
@hhyyrylainen
Copy link
Member

Upon reading the latest commit it does seem a bit better.

It seems the flee signal would now get emitted, it does still seem that the other signals are very easy to overwrite with the non-command. But I think this might be about ready for playtesting.

@IdfbAn IdfbAn marked this pull request as ready for review February 23, 2026 15:46
@IdfbAn IdfbAn requested review from a team February 24, 2026 10:03
Comment on lines +273 to +276
else
{
signalExists = false;
}
Copy link
Contributor

@Patryk26g Patryk26g Feb 24, 2026

Choose a reason for hiding this comment

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

is this "else" needed? can do without it, just make "bool signalExists = signaling.ReceivedCommand != MicrobeSignalCommand.None && entity.IsAliveAndHas()". Btw what is " entity.IsAliveAndHas()" used for? Shouldn't it be "signaling.ReceivedCommandFromEntity.IsAliveAndHas()"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw what is " entity.IsAliveAndHas()" used for?

It's so that the game doesn't crash when there isn't a signal.

Copy link
Contributor

Choose a reason for hiding this comment

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

This else still should be removed... it literally if signal == false then signal = false

private void UseSignalingAgent(ref OrganelleContainer organelles, float speciesAggression,
ref CommandSignaler signaling, Random random)
{
var willBeAggressiveThisTime = RollCheck(speciesAggression, Constants.MAX_SPECIES_AGGRESSION, random);
Copy link
Contributor

Choose a reason for hiding this comment

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

willBeAggressiveThisTime -> shouldBecomeAggresive

Copy link
Member Author

Choose a reason for hiding this comment

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

Personally, I think that's an inaccurate name considering what the variable is being used for.

Copy link
Contributor

@Patryk26g Patryk26g Feb 24, 2026

Choose a reason for hiding this comment

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

As I said in other comment, future tense variables should be omitted.

signaling.QueuedSignalingCommand = MicrobeSignalCommand.None;
}
}
else
Copy link
Contributor

Choose a reason for hiding this comment

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

this else is unnecesary

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess it is right now, but since I want to add more sub-conditions I'll keep it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you going to do this in this PR? If not, then you should remove it. YAGNI

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'm gonna do it in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

So there was unimplemented stuff? Good thing that I didn't spend any more review energy yet...


// Adjusted behaviour values (calculated here as these are needed by various methods)
var speciesBehaviour = ourSpecies.Species.Behaviour;
var willAdjustBehaviourValues = signaling.ReceivedCommand == MicrobeSignalCommand.BecomeAggressive &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should omit future tense in variables... adjustBehaviourValues is fine. or event better "shouldBeAggresive"

Copy link
Member

Choose a reason for hiding this comment

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

You know, I never thought about it, but you are right that future tense is not used in variable names customarily. So yeah, this sounds like a good naming change, and I would definitely have named this variable something along the lines of needsToAdjustBehaviour.

bool signalExists = signaling.ReceivedCommand != MicrobeSignalCommand.None &&
entity.IsAliveAndHas<WorldPosition>();
Vector3 signalerPosition = default;
float squaredDistanceToSignaler = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

squaredDistanceToSignaler -> signalerDistanceSquared

@IdfbAn IdfbAn marked this pull request as draft February 25, 2026 07:53
ai.ATPThreshold = 0.0f;
}

// Use signaling agent if I have any with a small chance per think
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be "per tick"?

Copy link
Member

Choose a reason for hiding this comment

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

I hope not because we do not have "ticks" in the game (the closest concept we have is a game simulation update)...

Copy link
Member Author

Choose a reason for hiding this comment

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

I do mean "think", as in each time AIThink() is called. I guess it should say "per update", then?

Copy link
Member

Choose a reason for hiding this comment

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

I think "per think" is perfectly understandable, and I have a feeling that there are existing comments that are of similar format. But for clarity it could be written as "per think method call".

private void UseSignalingAgent(ref OrganelleContainer organelles, float speciesAggression,
ref CommandSignaler signaling, Random random)
{
var shouldBeAggressive = RollCheck(speciesAggression, Constants.MAX_SPECIES_AGGRESSION, random);
Copy link
Contributor

@Accidental-Explorer Accidental-Explorer Feb 26, 2026

Choose a reason for hiding this comment

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

So this, combined with the section below is just deciding whether they should be trying to travel in a group? (Because this is outside specific responses, just passive, right?)

I think this would make sense not just for aggressive predators, but also for some Brave prey.

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

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

AI should know how to use the signaling agent to send commands

5 participants