Open
Description
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
- Do nothing. (Requires
# pyright:ignore
). - 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] = []
- 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!
Metadata
Metadata
Assignees
Labels
No labels