persist attack through attacker transformation - #341
Conversation
|
Here's an example demonstrating the need. The https://github.com/user-attachments/assets/1ca37563-35df-4959-8374-b652a27bf8b4 |
There was a problem hiding this comment.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
core/PhysiCell_cell.cpp:1134
- [nitpick] Consider using 'nullptr' instead of 'NULL' to align with modern C++ practices.
if ( phenotype.cell_interactions.pAttackTarget != NULL )
|
Came across this again and adding some more concrete code details.
Thus, the copied |
|
Can we make attack a conserved vs not property? |
|
Need a new PR where the attack persists through transformation. |
Invert the decision made earlier on this branch. Transformation now leaves an in-progress attack running instead of ending it. `pAttackTarget` lives in `phenotype.cell_interactions`, so `phenotype = cd.phenotype` would drop it; hold it across the assignment and put it back. The other two halves of the attack link -- the target's `attacked_by` and the shared spring -- live in `state`, which transformation already leaves alone, so restoring `pAttackTarget` keeps all three consistent without touching the spring. This also makes transformation symmetric: attacks *against* a transforming cell already persisted, while attacks *by* it were ended.
92edcf9 to
cc6b4ae
Compare
It lives in phenotype.cell_interactions too, so the transformation reset the attacker's lifetime damage tally to zero -- now visibly wrong when the attack it was counting is still running afterwards.
Rebased onto current
developmentand inverted relative to this PR's original direction: transformation now keeps an in-progress attack running instead of ending it.Background
pAttackTargetlives inphenotype.cell_interactions, sophenotype = cd.phenotypeinconvert_to_cell_definitiondrops it.state.attacked_byand the shared spring — live instate, which transformation leaves alone.Since #422 landed the symmetric attack link,
convert_to_cell_definitionresolved that mismatch by callingremove_self_from_attacked()to end the attack. This PR resolves it the other way: holdpAttackTargetacross the assignment and put it back. All three parts of the link then stay consistent, and the spring is never touched.This also makes transformation symmetric — attacks against a transforming cell already persisted, while attacks by it were ended.
total_damage_deliveredis carried across too (second commit). It also lives inphenotype.cell_interactions, so transformation was resetting the attacker's lifetime damage tally to zero — visibly wrong now that the attack it was counting keeps running afterwards.Verification
Built and ran
interaction-samplewithCD8+ T cell -> neutrophiltransformation enabled and a 30 min attack duration. At each transformation of an attacking cell, all three parts of the link survive:interactionsandrules_sampleare the only sample configs with both nonzero attack and transformation rates, and neither is SVG-diff-checked in CI, so no snapshot changes are expected.Known gap
The same run shows the case worth flagging:
The transformed cell keeps attacking a cell type its new definition has a zero attack rate against — an attack it could never have started — and with unset attack parameters the defaults (
attack_damage_rate = 1.0,attack_duration = 30 min) let that run on.Handled separately in #432, which warns about exactly this case without changing the simulation.