Skip to content

Commit c926593

Browse files
nyksansCopilot
andauthored
Update examples/energy_expenditure/model.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 844bf98 commit c926593

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

examples/energy_expenditure/model.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ def rest(self):
6161
self.energy += 1
6262

6363
def die(self):
64-
"""Safely remove agent from grid and model."""
65-
self.model.grid.remove_agent(self)
64+
"""Safely remove agent from grid, model, and custom tracking."""
65+
# First deregister from Mesa's model and grid tracking
66+
self.remove()
67+
# Then keep the model's custom agents_list in sync
6668
self.model.remove_agent(self)
6769

6870

0 commit comments

Comments
 (0)