Wrapper#

class drama.wrapper.RestrictionWrapper(env: AECEnv, restrictors: dict | Restrictor, *, agent_restrictor_mapping: dict | None = None, restrictor_reward_fns: dict | Callable = None, preprocess_restrictor_observation_fns: dict | Callable = None, postprocess_restriction_fns: dict | Callable = None, restriction_violation_fns: dict | Callable = None, restriction_key: str = 'restriction', observation_key: str = 'observation', return_object: bool = False, **kwargs)[source]#

Wrapper that implements the agent-restrictor-environment loop of DRAMA:

Reset() -> Restrictor of Agent_0 -> Step() -> Agent_0 -> Step() -> Restrictor of Agent_1 -> Step() -> Agent_1 -> …

action_space(agent)[source]#

Takes in agent or restrictor and returns the action space for that agent or restrictor.

observation_space(agent)[source]#

Takes in agent or restrictor and returns the observation space for that agent or restrictor.

observe(agent: str, return_object: bool = None, **kwargs)[source]#

Returns the observation an agent or restrictor currently can make.

last() calls this function.

reset(seed=None, options=None)[source]#

Resets the agent-restrictor-environment loop to a starting state.

step(action)[source]#

Accepts and executes the action or restriction of the current agent_selection in the environment.

Automatically switches control between the agents and restrictors.

wrapper._default_restrictor_reward_fn(rewards)#

Default restrictor reward function as the social welfare.

Parameters:
  • env – The environment after the agent step was taken

  • rewards – The rewards of each agent

Returns:

The restrictor reward

wrapper._default_preprocess_restrictor_observation_fn()#

Default pre-processing of the restrictor observation.

Parameters:

env – The environment at the point in time

Returns:

The restrictor observation

wrapper._default_postprocess_restriction_fn()#

Default post-processing of the restriction.

Parameters:

restriction – The restriction derived from the restrictor

Returns:

The post-processed restriction

wrapper._default_restriction_violation_fn(action, restriction: Restriction)#

Default handling of restriction violations.

Parameters:
  • env – The environment after the agent step was taken

  • action – The action which violated the restriction

  • restriction – The restriction object corresponding to the action

Raises:

RestrictionViolationException – If the restriction is violated