How to use the aiomas.Agent function in aiomas

To help you get started, we’ve selected a few aiomas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frnsys / system_designer / syd / agent / base.py View on Github external
# extract vars required by behaviors
        # can handle partials as well
        all_required_vars = set(sum((
            b.required_vars if not isinstance(b, partial)
            else b.func.required_vars
            for b in behaviors
        ), []))

        missing = [var for var in all_required_vars
                   if var not in state_vars]
        if missing:
            raise MissingVarError('required vars {} are missing in agent `state_vars`'.format(missing))
        return type.__new__(cls, name, parents, dct)


class Agent(aiomas.Agent, metaclass=AgentMeta):
    state_vars = []
    behaviors = []

    def __init__(self, container, state, *args, world_addr=None, **kwargs):
        super().__init__(container)
        self.state = self.State(**state)
        self.world_addr = world_addr
        self._updates = []
        self.init(state, *args, **kwargs)

    def init(self, state, *args, **kwargs):
        """initialization for an agent. you should
        override this method instead of `__init__`."""
        pass

    async def emit(self, name, *args, **kwargs):

aiomas

Asyncio-based, layered networking library providing request-reply channels, RPC, and multi-agent systems.

MIT
Latest version published 7 years ago

Package Health Score

39 / 100
Full package analysis