Agent is missing __repr__ inconsistent with every other core Mesa class
SUMMARY
Agent defines __str__ but not __repr__. This means repr(agent) falls back to object.__repr__, returning a useless memory address that changes every run.
This makes agents invisible in debuggers, logging output, and interactive shells.
Current behaviour
class Wolf(Agent):
pass
model = Model()
wolf = Wolf(model)
print(str(wolf)) # Wolf, agent_id = 0
print(repr(wolf))
Expected behaviour
print(repr(wolf)) # Wolf(unique_id=0)
This is an internal inconsistency
Every other core Mesa class already defines __repr__. Agent is the only one that was skipped. The pattern is already established in the codebase. Agent was one core object where it was never defined.
Precedent
PR #2195 added __repr__ to EventList for exactly this reason. Same fix.
I'd like to submit a PR for this
I agree with addressing this, and we probably should open an issue to add __repr_html__ to most base classes (i.e., Model, Agent, AgentSet`, and the various spaces).
Should i open an issue regarding adding repr_html to the base classes and start working on adding it?