Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 921 Bytes

create_agent.rst

File metadata and controls

29 lines (20 loc) · 921 Bytes

Implementing Agent Classes

All agents used in Creamas must inherit from :py~creamas.core.agent.CreativeAgent. They should also accept the agent's ~creamas.core.environment.Environment as the first parameter in their __init__. The environment should then be passed on to :pysuper().__init__.

Each agent class should call :pysuper().__init__ as one of the first things in :py__init__, for example:

from creamas import CreativeAgent, Environment

class MyAgent(CreativeAgent):

    def __init__(self, environment, *args, **kwargs):
        self.my_arg = kwargs.pop('my_arg', None)
        super().__init__(environment, *args, **kwargs)
        # Your own initialization code

env = Environment.create(('localhost', 5555))
agent = MyAgent(env, my_arg=5)
# do stuff
env.close()