mlpy.agents.world.WorldModel

class mlpy.agents.world.WorldModel[source]

Bases: mlpy.modules.Module

The world model.

The world model manages the world objects of type WorldObject by ensuring that the objects are updated with the latest information at every time step of the program loop. Furthermore, information of the world objects can be accessed from the world model.

Notes

The world module follows the singleton design pattern (Singleton), ensuring only one instances of the world module exist. This allows for accessing the information of the world model from anywhere in the program.

Examples

>>> from mlpy.agents.world import WorldModel, WorldObject
>>> WorldModel().add_object("ball", WorldObject)
>>> from mlpy.agents.world import WorldModel
>>> ball = WorldModel().get_object("ball")

Attributes

mid The module’s unique identifier.

Methods

add_object(name, obj) Add a world object.
enter(t) Enter the world model.
exit() Perform cleanup tasks and exit the module.
get_object(name) Returns the object with the given name.
init() Initialize the module.
load(filename) Load the state of the module from file.
save(filename) Save the current state of the module to file.
update(dt) Update all world objects.