Skip to content

[Enhancement]: Consider using a key-based structure for agentsets instead of list in AgentsDf #146

@Ben-geo

Description

@Ben-geo

🤔 Problem Description

Currently, agentsets are stored in a list (e.g., self.agentsets[0] for sheep, self.agentsets[1] for wolves in wolf-sheep model ), which relies on indexing. While functional, this can be slightly confusing, especially in models with multiple agent types.

Accessing agentsets by name (e.g., "sheep" or "wolves") instead of an index would make the code more readable, less error-prone, and easier to maintain

💡 Proposed Solution

One possibility is to use a key-value structure for storing agentsets—such as a dictionary— open to other approaches as well. The key idea is to allow referencing agentsets with descriptive identifiers rather than implicit positions.


self.agentsets = {
    "sheep": sheep_agentset,
    "wolves": wolf_agentset
}

maybe we can pass in the name when agentsets are added

This could make code that works with specific agent types more intuitive, while still allowing for easy iteration using .values().

Curious if there was a specific reason behind the current list-based design—happy to hear thoughts or alternative ideas!

🔄 Alternatives Considered

No response

➕ Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Sprints!A task that might be good to tackle during sprints!enhancementImprovements to existing features or performance.good first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions