Skip to content

Fix ActionIfIsolated::DoNothing infinite loop when all species are isolated#145

Merged
HyperCodec merged 3 commits intospeciation-rewritefrom
copilot/sub-pr-144
Mar 10, 2026
Merged

Fix ActionIfIsolated::DoNothing infinite loop when all species are isolated#145
HyperCodec merged 3 commits intospeciation-rewritefrom
copilot/sub-pr-144

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

When ActionIfIsolated::DoNothing is selected and every species has fewer than 2 members, the repopulation loop spins forever — i is never incremented because every iteration hits continue without producing an offspring.

Changes

  • Pre-loop guard in SpeciatedCrossoverRepopulator::repopulate: Before entering the main loop, checks whether any species has ≥ 2 members when DoNothing is active. If none do, delegates immediately to inner.repopulate and returns — ensuring the loop is never entered in the degenerate case.
  • Updated DoNothing doc comment: Documents the fallback behaviour instead of the previous note that a hang was "possible".
// New guard before the main loop
if matches!(self.action_if_isolated, ActionIfIsolated::DoNothing)
    && !population.species.iter().any(|s| s.len() >= 2)
{
    self.inner.repopulate(genomes, target_size);
    return;
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on the speciation feature rewrite Fix ActionIfIsolated::DoNothing infinite loop when all species are isolated Mar 10, 2026
@HyperCodec HyperCodec marked this pull request as ready for review March 10, 2026 11:51
@HyperCodec HyperCodec merged commit 2f79778 into speciation-rewrite Mar 10, 2026
3 checks passed
@HyperCodec HyperCodec deleted the copilot/sub-pr-144 branch March 10, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants