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)[源代码]

基类: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[源代码]
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[源代码]

基类:ABC

Representing an env whose value can be gotten.

abstract get() Any[源代码]

Get the value of the env.

返回:

The value of the env.

返回类型:

Any

class agentscope.environment.event.Setable[源代码]

基类:ABC

Representing an env whose value can be set.

abstract set(value: Any) bool[源代码]

Set the value of the env.

参数:

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

返回:

Whether the value was set successfully.

返回类型:

bool

class agentscope.environment.event.Movable2D[源代码]

基类:ABC

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

abstract move_by(x: float, y: float) bool[源代码]

Move the env in 2D by the given vector.

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

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

返回:

Whether the movement was successful.

返回类型:

bool

abstract move_to(x: float, y: float) bool[源代码]

Move the env to the given position.

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

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

返回:

Whether the movement was successful.

返回类型:

bool

abstract get_position() Tuple[float, float][源代码]

Get the position of the env.

返回:

The position of the env.

返回类型:

Tuple[float, float]

class agentscope.environment.event.Holdable[源代码]

基类: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[源代码]

Acquire the env.

参数:

owner (str) – The owner of the env.

返回:

Whether the env was acquired successfully.

返回类型:

bool

abstract release(owner: str) bool[源代码]

Release the env.

参数:

owner (str) – The owner of the env.

返回:

Whether the env was released successfully.

返回类型:

bool