Skip to content

Commit

Permalink
add agent to model.agent correctly even if super was not called
Browse files Browse the repository at this point in the history
fix for the second issue in projectmesa#2006. If super is not present, we create the data structure but forget to add the agent to it. This is just a backward compatibility fix.
  • Loading branch information
quaquel committed Jan 26, 2024
1 parent ef31723 commit 430d6f7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mesa/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, unique_id: int, model: Model) -> None:
except AttributeError:
# model super has not been called
self.model.agents_ = defaultdict(dict)
self.model.agents_[type(self)][self] = None
self.model.agentset_experimental_warning_given = False

warnings.warn(
Expand Down

0 comments on commit 430d6f7

Please sign in to comment.