swarmsim.world#

Houses World modules.

Worlds are the root of the simulation.

All worlds must inherit from World

The world is simulated by the simulate module.

Subpackages

Functions#

swarmsim.world.World.World_from_config(config: dict)[source]

Returns a new world instance from the given config.

Parameters:

config (dict | WorldConfig) –

The config to create the world from.

The config should either be a dict with a 'type' key, or an instance of AbstractWorldConfig with an associated_type field (which can be set using @~swarmsim.config.associated_type ).

The Configuration System will be used to lookup the class for the world type.

Returns:

A new world of type config['associated_type'] or config.associated_type.

Return type:

World

swarmsim.world.World.config_from_dict(d: dict)[source]

Create a world config dataclass from a dict.

Parameters:

d (dict) –

The dict to create the world config from.

Must have a ‘type’ key that specifies the world type as a string.

Returns:

Returns a dataclass of the world config. The type of the dataclass is determined by the ‘type’ key in the dict.

Return type:

dataclass

Raises:
  • ValueError – Raised if the dict does not have a ‘type’ key.

  • IndexError – Raised if the world type is not found in the registry.

swarmsim.world.World.config_from_yaml(path: str | PathLike)[source]

Load a YAML file and return a config object.

swarmsim.world.World.config_from_yamls(s: str | Any)[source]

Load a YAML string or stream and return a config object.

Modules