Skip to content

Fix tests for periodic front angle update mechanism#562

Merged
chrxh merged 9 commits intofeatures/CreatureCheckfrom
copilot/repair-cell-death-tests
Mar 21, 2026
Merged

Fix tests for periodic front angle update mechanism#562
chrxh merged 9 commits intofeatures/CreatureCheckfrom
copilot/repair-cell-death-tests

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

The new front angle update logic (d5e08f15) increments creature->frontAngleId every Cell::UpdateInterval (100) timesteps and increments lastUpdate unconditionally for all non-head cells. Cells with lastUpdate > 110 transition to CellState_Dying. This means any creature without a headCell will have its cells die after ~111 timesteps, breaking 200+ tests.

CellStateTransitionTests

  • Removed CellDeathConsequences parameterization (no longer exists in kernel)
  • Removed Detaching propagation tests (mechanism removed)
  • Added lastUpdate-based death tests: threshold check, fixed cell exemption, head cell exemption

FrontAngleUpdateTests

  • noUpdate_equalFrontAngleId: periodic mechanism now bumps creature->frontAngleId even when initially equal — updated expectations to expect propagated front angle values

MuscleTests, PhysicsTests, ConstructorTests, CreatureTests, EnergyFlowTests, BalanceTests, GeneratorTests

  • Added headCell(true) to an appropriate cell in each test creature
  • Added GenomeDesc().frontAngle(...) matching the muscle cell's explicit front angle where needed

EntityFactory bug fix

  • EntityFactory::createCellFromNode was missing cell.lastUpdate = 0 initialization. Newly constructed cells inherited garbage values from CUDA heap memory, causing them to immediately transition to CellState_Dying when lastUpdate > 110. This only manifested when running tests non-isolated (due to CUDA heap memory reuse from previous tests).

ConstructorTests_BendingMuscles fix

  • Updated resetBendingMuscle test expectation from InitialFrontAngleId + 1 to InitialFrontAngleId + 2 — at timestep 0, both the periodic mechanism (timestep % 100 == 0) and activateNewObjectOnLastNode each bump creature->frontAngleId.

Example fix pattern for muscle tests:

// Before: cells die after ~111 timesteps (no head cell)
auto data = Desc().addCreature(
    { ObjectDesc().id(1).pos({10.0f, 10.0f}),
      ObjectDesc().id(2).pos({11.0f, 10.0f})
          .type(CellDesc().frontAngle(-90.0f).cellType(MuscleDesc()...)) },
    CreatureDesc().id(0));

// After: muscle cell is head cell, gets frontAngle from genome, propagates to neighbors
auto data = Desc().addCreature(
    { ObjectDesc().id(1).pos({10.0f, 10.0f}).type(CellDesc().headCell(true)),
      ObjectDesc().id(2).pos({11.0f, 10.0f})
          .type(CellDesc().frontAngle(-90.0f).headCell(true).cellType(MuscleDesc()...)) },
    CreatureDesc().id(0), GenomeDesc().frontAngle(-90.0f));

Verified: All 204 ConstructorTests pass (201 pass, 3 pre-existing skips). All 144 FrontAngleUpdate + Physics + Muscle tests pass.


💡 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.

…erization, add lastUpdate tests

Co-authored-by: chrxh <73127001+chrxh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tests for cell death consequences and update logic Repair CellStateTransitionTests for lastUpdate-based cell death logic Mar 20, 2026
Copilot AI requested a review from chrxh March 20, 2026 07:48
Copilot AI changed the title Repair CellStateTransitionTests for lastUpdate-based cell death logic Fix CellStateTransitionTests after cellDeathConsequences removal Mar 20, 2026
Add headCell(true) to all cells in tests that run >110 timesteps to prevent
cell death from the new lastUpdate mechanism. Without a head cell, non-head
cells have their lastUpdate incremented every timestep and die when it
exceeds Cell::UpdateInterval + 10 (110).

Files fixed:
- FrontAngleUpdateTests: Update expectations for noUpdate_equalFrontAngleId
- MuscleTests: Add headCell(true) to all cells, GenomeDesc with matching
  frontAngle for muscle head cells
- PhysicsTests: Add headCell(true) to all cells in angular force and ghost tests
- EnergyFlowTests: Add headCell(true) to all cells in long-running tests
- GeneratorTests: Add headCell(true) to generator cells in >110 timestep tests
- BalanceTests: Add headCell(true) to seed constructor cells
- ConstructorTests: Add headCell(true) to cells in long-running tests
- CreatureTests: Add headCell(true) to constructor seed cells

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI changed the title Fix CellStateTransitionTests after cellDeathConsequences removal Fix tests for periodic front angle update mechanism Mar 20, 2026
@chrxh
Copy link
Owner

chrxh commented Mar 21, 2026

@copilot Try to make the test ConstructorTests_AllShapes::creature_3__generateShape running.
The tests are successful when running isolated. The failure has to do with the logic in frontAngleUpdate_calcFutureValue and frontAngleUpdate_applyFutureValue.
Try to debug with printf there to find the reason for failing.

…fix BendingMuscles frontAngleId expectation

Co-authored-by: chrxh <73127001+chrxh@users.noreply.github.com>
Agent-Logs-Url: https://github.com/chrxh/alien/sessions/e5955d01-d7a1-48a3-864c-36cc7510ca21
Copy link
Contributor Author

Copilot AI commented Mar 21, 2026

@copilot Try to make the test ConstructorTests_AllShapes::creature_3__generateShape running.
The tests are successful when running isolated. The failure has to do with the logic in fr...

Fixed in 36d9f11. Root cause: EntityFactory::createCellFromNode did not initialize cell.lastUpdate = 0, so newly constructed cells inherited garbage values from the CUDA heap. When running non-isolated, heap memory from previous tests contained non-zero lastUpdate values (>110), causing constructed cells to immediately transition to CellState_Dying.

Two fixes:

  1. EntityFactory.cuh: Added cell.lastUpdate = 0; in createCellFromNode to properly initialize the field
  2. ConstructorTests.cpp: Updated ConstructorTests_BendingMuscles::resetBendingMuscle expectation from InitialFrontAngleId + 1 to InitialFrontAngleId + 2 — at timestep 0, both the periodic mechanism (timestep % 100 == 0) and activateNewObjectOnLastNode each bump creature->frontAngleId

All 204 ConstructorTests now pass (201 pass, 3 pre-existing skips).

@chrxh chrxh marked this pull request as ready for review March 21, 2026 10:53
@chrxh chrxh merged commit 2fe62a5 into features/CreatureCheck Mar 21, 2026
@chrxh chrxh deleted the copilot/repair-cell-death-tests branch March 21, 2026 10: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