object and objects are now private

This commit is contained in:
Chanumask
2023-10-23 16:44:03 +02:00
parent e87bd3aaa0
commit c4ffdb4e44
11 changed files with 30 additions and 30 deletions

View File

@ -1,8 +1,8 @@
from marl_factory_grid.environment.groups.objects import Objects
from marl_factory_grid.environment.groups.objects import _Objects
from marl_factory_grid.environment.entity.object import EnvObject
class Collection(Objects):
class Collection(_Objects):
_entity = EnvObject
@property

View File

@ -3,12 +3,12 @@ from operator import itemgetter
from random import shuffle
from typing import Dict
from marl_factory_grid.environment.groups.objects import Objects
from marl_factory_grid.environment.groups.objects import _Objects
from marl_factory_grid.utils.helpers import POS_MASK
class Entities(Objects):
_entity = Objects
class Entities(_Objects):
_entity = _Objects
@staticmethod
def neighboring_positions(pos):

View File

@ -3,12 +3,12 @@ from typing import List
import numpy as np
from marl_factory_grid.environment.entity.object import Object
from marl_factory_grid.environment.entity.object import _Object
import marl_factory_grid.environment.constants as c
class Objects:
_entity = Object
class _Objects:
_entity = _Object
@property
def observers(self):
@ -129,8 +129,8 @@ class Objects:
self.add_items([self._entity() for _ in range(n)])
return c.VALID
def despawn(self, items: List[Object]):
items = [items] if isinstance(items, Object) else items
def despawn(self, items: List[_Object]):
items = [items] if isinstance(items, _Object) else items
for item in items:
del self[item]
@ -145,7 +145,7 @@ class Objects:
# except (ValueError, AttributeError):
# pass
def notify_del_entity(self, entity: Object):
def notify_del_entity(self, entity: _Object):
try:
entity.del_observer(self)
except AttributeError:
@ -155,7 +155,7 @@ class Objects:
except (AttributeError, ValueError, IndexError):
pass
def notify_add_entity(self, entity: Object):
def notify_add_entity(self, entity: _Object):
try:
if self not in entity.observers:
entity.add_observer(self)

View File

@ -5,7 +5,7 @@ import numpy as np
from marl_factory_grid.environment.entity.util import GlobalPosition
from marl_factory_grid.environment.groups.collection import Collection
from marl_factory_grid.environment.groups.mixins import PositionMixin, HasBoundMixin
from marl_factory_grid.environment.groups.objects import Objects
from marl_factory_grid.environment.groups.objects import _Objects
from marl_factory_grid.modules.zones import Zone
from marl_factory_grid.utils import helpers as h
from marl_factory_grid.environment import constants as c