Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributes defined for specific instances only #3

Open
dylwil3 opened this issue Jun 11, 2023 · 0 comments
Open

Attributes defined for specific instances only #3

dylwil3 opened this issue Jun 11, 2023 · 0 comments

Comments

@dylwil3
Copy link
Collaborator

dylwil3 commented Jun 11, 2023

This issue is a place to discuss the conventions for attributes which are defined for a specific instance of a class only.

Here is a concrete example. In the current implementation of the World class, we have:

class World:  # multi-agent world
    def __init__(self):
        # list of agents and entities (can change at execution-time!)
        self.agents = []
        self.landmarks = []
        # communication channel dimensionality
        self.dim_c = 0
        # position dimensionality
        self.dim_p = 2
        # color dimensionality
        self.dim_color = 3
        # simulation timestep
        self.dt = 0.1
        # physical damping
        self.damping = 0.25
        # contact response parameters
        self.contact_force = 1e2
        self.contact_margin = 1e-3

In particular, there is no attribute called food. However, in the code for the Scenario of Simple World Comm, we see:

class Scenario(BaseScenario):
    def make_world(
        self,
        num_good_agents=2,
        num_adversaries=4,
        num_landmarks=1,
        num_food=2,
        num_forests=2,
    ):
        world = World()
        ...
        # add agents
        world.agents = [Agent() for i in range(num_agents)]
        ...
        world.food = [Landmark() for i in range(num_food)]
        ...

Proposals

  1. Do nothing. (Requires # pyright:ignore).
  2. Change definition of World to include:
...
self.food = []

This still requires # pyright : ignore.
(NB : While it's not the case for this specific example, if we had to do something like self.attribute = None, we would then be in the situation of Issue #2 .)
3. Change definition of World to include:

...
self.food : list[Landmark] = []
  1. Something else.

In the current PR #1 , I've chosen option 3. I'm not wedded to this.

Would love to hear people's thoughts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant