smarts.core.agent module¶
-
class
smarts.core.agent.
Agent
[source]¶ The base class for agents
-
class
smarts.core.agent.
AgentSpec
(interface: Optional[smarts.core.agent_interface.AgentInterface] = None, agent_builder: Optional[Callable[[...], smarts.core.agent.Agent]] = None, agent_params: Optional[Any] = None, policy_builder: Optional[Callable[[...], smarts.core.agent.Agent]] = None, policy_params: Optional[Any] = None, observation_adapter: Callable = <function AgentSpec.<lambda>>, action_adapter: Callable = <function AgentSpec.<lambda>>, reward_adapter: Callable = <function AgentSpec.<lambda>>, info_adapter: Callable = <function AgentSpec.<lambda>>, perform_self_test: bool = False)[source]¶ A configuration that is used by SMARTS environments.
agent_spec = AgentSpec( interface=AgentInterface.from_type(AgentType.Laner), agent_params={"agent_function": lambda _: "keep_lane"}, agent_builder=AgentPolicy.from_function, ) env = gym.make( "smarts.env:hiway-v0", scenarios=["scenarios/loop"], agent_specs={agent_id: agent_spec}, ) agent = agent_spec.build_agent()
Refer to the Agent documentation.
-
action_adapter
()¶ An adaptor that allows shaping of the action (default lambda act: act)
-
agent_builder
: Callable[[…], smarts.core.agent.Agent] = None¶ A callable to build an smarts.core.agent.Agent given AgentSpec.agent_params (default None)
-
agent_params
: Optional[Any] = None¶ Parameters to be given to AgentSpec.agent_builder (default None)
-
build_agent
() → smarts.core.agent.Agent[source]¶ Construct an Agent from the AgentSpec configuration.
-
info_adapter
(reward, info)¶ An adaptor that allows shaping of info (default lambda obs, reward, info: info)
-
interface
: smarts.core.agent_interface.AgentInterface = None¶ the adaptor used to wrap agent observation and action flow (default None)
-
observation_adapter
()¶ An adaptor that allows shaping of the observations (default lambda obs: obs)
-
perform_self_test
: bool = False¶ [DEPRECATED] this parameter is not used anymore
-
policy_builder
: Callable[[…], smarts.core.agent.Agent] = None¶ [DEPRECATED] see AgentSpec.agent_builder (default None)
-
policy_params
: Optional[Any] = None¶ [DEPRECATED] see AgentSpec.agent_params (default None)
-
replace
(**kwargs) → smarts.core.agent.AgentSpec[source]¶ Return a copy of this AgentSpec with the given fields updated.
-
reward_adapter
(reward)¶ An adaptor that allows shaping of the reward (default lambda obs, reward: reward)
-