Beispiel #1
0
    def __init__(self,
                 name,
                 attrs=None,
                 action=None,
                 duration=INF,
                 prim_group=None,
                 serial_obj=None,
                 reg=True,
                 **kwargs):
        self.registry = {}

        self.execution_key = CLI_EXEC_KEY

        if EXEC_KEY in kwargs:
            self.execution_key = kwargs[EXEC_KEY]

        if serial_obj is not None:
            self.restore(serial_obj)
        else:  # or build it anew:
            self._construct_anew(name,
                                 attrs=attrs,
                                 action=action,
                                 duration=duration,
                                 prim_group=prim_group,
                                 reg=reg)
        if reg:
            register(self.name, self, execution_key=self.execution_key)
Beispiel #2
0
    def __init__(self, name, width=DEF_WIDTH, height=DEF_HEIGHT,
                 attrs=None, members=None, action=None,
                 random_placing=True, serial_obj=None, reg=True, **kwargs):
        super().__init__(name, attrs=attrs, members=members,
                         action=action, serial_obj=serial_obj,
                         reg=False, **kwargs)

        self.execution_key = CLI_EXEC_KEY
        if EXEC_KEY in kwargs:
            self.execution_key = kwargs[EXEC_KEY]
        self.type = type(self).__name__
        if serial_obj is not None:
            self.restore(serial_obj)
        else:
            self.width = width
            self.height = height
            # the location of members in the space {(tuple):Agent}
            self.locations = {}
            # by making two class methods for rand_place_members and
            # place_member, we allow two places to override
            self.random_placing = random_placing
            if random_placing:
                self.rand_place_members(self.members)
            else:
                self.consec_place_members(self.members)
        if reg:
            register(self.name, self, execution_key=self.execution_key)
Beispiel #3
0
 def handle_womb(self):
     """
     The womb just contains group names -- they will be repeated
     as many times as that group needs to add members.
     We name the new members in the `member_creator()` method.
     This should be re-written as dict with:
         {"group_name": #agents_to_create}
     """
     if self.womb is not None:
         for group_nm in self.womb:
             group = regis.get_group(group_nm,
                                     execution_key=self.execution_key)
             if group is not None and group.member_creator is not None:
                 group.num_members_ever += 1
                 agent = group \
                     .member_creator("", group.num_members_ever,
                                     execution_key=self.execution_key)
                 regis.register(agent.name,
                                agent,
                                execution_key=self.execution_key)
                 join(group, agent)
             if self.random_placing:
                 self.place_member(agent, None)
         self.womb.clear()
Beispiel #4
0
 def __init__(cls, name, bases, attrs):
     """
     Metaclass to ensure that all task classes are registered
     """
     registry.register(cls)
Beispiel #5
0
# -*- coding: utf-8 -*-

__version__ = '0.1.0'


from registry import registry
from config import LikeDislikeRatingConfig


registry.register(LikeDislikeRatingConfig)
Beispiel #6
0
 def __init__(cls, name, bases, attrs):
     """
     Metaclass to ensure that all task classes are registered
     """
     registry.register(cls)