I propose putting all optional functions, provided, and @provide in an Optional submodule.
I think we should also have a Default submodule that implements defaults wherever possible.
For example:
Default.clone(env::AbstractEnv) = deepcopy(env)
or
function Default.valid_actions(env::AbstractEnv)
if provided(Optional.valid_actions, env)
return Optional.valid_actions(env)
elseif provided(Optional.valid_action_mask, env)
return actions(env)[Optional.valid_action_mask(env)]
else
return actions(env)
end
end
If a solver/agent wants to know whether an environment explicitly provides some optional behavior, they could use provided, but if they want to use it for any environment and automatically fall back to the default, they can use, and it will work for any env.
using CommonRLInterface.Default: valid_actions
valid_actions(env) # will work for any environment
Optional.valid_actions(env) # will throw a MethodError if the environment does not implement `valid_actions`
I propose putting all optional functions,
provided
, and@provide
in anOptional
submodule.I think we should also have a
Default
submodule that implements defaults wherever possible.For example:
or
If a solver/agent wants to know whether an environment explicitly provides some optional behavior, they could use
provided
, but if they want to use it for any environment and automatically fall back to the default, they can use, and it will work for any env.