AgentComponent¶
Requires the rl package to be installed for the project.
AgentComponent ¶
action
property
¶
action: Any
The most recent action, in whatever type matches the configured action_space (int for Discrete, list for Box/MultiDiscrete/MultiBinary).
Example
move_idx, jump, shoot = self.agent.action # MultiDiscrete([3, 2, 2])
action_space
property
¶
action_space: Any
The gymnasium.spaces.Space configured via set_action_space()
observation_space
property
¶
observation_space: Any
The gymnasium.spaces.Space configured via set_observation_space(), or None if unset
add_component ¶
add_component(component_class: Any) -> typing.Any
Attach a new component of the given type to this component's owning Object.
Example
render = self.add_component(RenderComponent)
add_object ¶
add_object(obj: Object, parent: Object = None) -> Object
Add a newly created Object to the scene, optionally parented to another Object
add_reward ¶
add_reward(delta: SupportsFloat | SupportsIndex) -> None
Add delta to this episode's accumulated reward
clear_observation ¶
clear_observation() -> None
Clear the observation vector accumulated so far this frame
end_episode ¶
end_episode() -> None
Mark the current episode as done, ending the RL rollout on the next step
get_component ¶
get_component(component_class: Any) -> typing.Any
Look up a component on this Object
has_component ¶
has_component(component_class: Any) -> bool
Check whether this component's owning Object has a component of the given type
remove_component ¶
remove_component(component_class: Any) -> None
Remove a component of the given type from this component's owning Object
set_action_space ¶
set_action_space(space: Any) -> None
Set this agent's action space to any gymnasium.spaces.Space instance (Discrete, Box, MultiDiscrete, MultiBinary).
Example
from gymnasium import spaces
self.agent.set_action_space(spaces.MultiDiscrete([3, 2, 2]))
Must be called (e.g. from OnStart) before training or inference.
set_observation ¶
set_observation(values: Sequence[SupportsFloat | SupportsIndex]) -> None
Replace this frame's entire observation vector
set_observation_space ¶
set_observation_space(space: Any) -> None
Optional. Override the observation space with any gymnasium.spaces.Space. If not set, a Box inferred from the length of accumulated add_observation() values is used automatically (previous default behavior).
set_reward ¶
set_reward(value: SupportsFloat | SupportsIndex) -> None
Overwrite this step's reward with value