agentscope.environment.event module

The events which can be bound to envs.

class agentscope.environment.event.Event(name: str, args: dict | None = None, returns: Any | None = None)[source]

Bases: object

A class representing the information of an event.

It contains the name of the event, the arguments of the event, and the returns of the event.

__init__(name: str, args: dict | None = None, returns: Any | None = None) None[source]
property name: str

Return the name of the event.

property args: dict

Return the arguments of the event.

property returns: Any

Return the returns of the event.

class agentscope.environment.event.Getable[source]

Bases: ABC

Representing an env whose value can be gotten.

abstract get() Any[source]

Get the value of the env.

Returns:

The value of the env.

Return type:

Any

class agentscope.environment.event.Setable[source]

Bases: ABC

Representing an env whose value can be set.

abstract set(value: Any) bool[source]

Set the value of the env.

Parameters:

value (Any) – The new value of the env.

Returns:

Whether the value was set successfully.

Return type:

bool

class agentscope.environment.event.Movable2D[source]

Bases: ABC

A class representing an env can be moved in 2D.

abstract move_by(x: float, y: float) bool[source]

Move the env in 2D by the given vector.

Parameters:
  • x (float) – The movement in x direction.

  • y (float) – The movement in y direction.

Returns:

Whether the movement was successful.

Return type:

bool

abstract move_to(x: float, y: float) bool[source]

Move the env to the given position.

Parameters:
  • x (float) – The x coordinate of the new position.

  • y (float) – The y coordinate of the new position.

Returns:

Whether the movement was successful.

Return type:

bool

abstract get_position() Tuple[float, float][source]

Get the position of the env.

Returns:

The position of the env.

Return type:

Tuple[float, float]

class agentscope.environment.event.Holdable[source]

Bases: ABC

A class representing an env can be held,and during the holding period, all access behaviors except the owner are prohibited.

abstract acquire(owner: str) bool[source]

Acquire the env.

Parameters:

owner (str) – The owner of the env.

Returns:

Whether the env was acquired successfully.

Return type:

bool

abstract release(owner: str) bool[source]

Release the env.

Parameters:

owner (str) – The owner of the env.

Returns:

Whether the env was released successfully.

Return type:

bool