|
bitsim
Model, simulate, estimate and control robots in C++
|
The base of environments where several agents act at the same time. More...
#include <multi_agent_env_base.h>
Public Types | |
| typedef ObservationType | observation_type |
| typedef ActionType | action_type |
| typedef MultiAgentTimeStep< ObservationType > | time_step_type |
| typedef std::vector< action_type > | joint_action_type |
| One action per agent, in the order of the agents. | |
Public Member Functions | |
| virtual | ~MultiAgentEnvBase ()=default |
| virtual void | make (const std::string &version, const std::unordered_map< std::string, std::any > &make_options, const std::unordered_map< std::string, std::any > &reset_options) |
| Build the environment. | |
| time_step_type | reset () |
| Start a new episode with the next seed. | |
| virtual time_step_type | reset (uint_t seed)=0 |
| Start a new episode with the given seed. | |
| virtual time_step_type | step (const joint_action_type &actions)=0 |
| Apply one action per agent. | |
| virtual void | close () |
| Release the environment; make() builds it again. | |
| uint_t | n_agents () const noexcept |
| const std::string & | agent_name (uint_t agent) const |
| The name of an agent, for printing. | |
| bool | is_created () const noexcept |
| std::string | env_name () const noexcept |
| std::string | version () const noexcept |
| uint_t | n_steps () const noexcept |
| The steps of the current episode so far. | |
| uint_t | max_steps () const noexcept |
| The steps after which an episode is truncated. | |
| uint_t | last_reset_seed () const noexcept |
| const std::unordered_map< std::string, std::any > & | make_options () const noexcept |
Static Public Attributes | |
| static constexpr uint_t | DEFAULT_ENV_SEED = 42 |
Protected Member Functions | |
| MultiAgentEnvBase (const std::string &name) | |
| void | set_agents_ (std::vector< std::string > names) |
| Name the agents; their number is the number of names. | |
| void | set_max_steps_ (uint_t max_steps) noexcept |
| void | make_created_ () noexcept |
| void | start_episode_ () noexcept |
| Start counting the steps of a new episode, for reset(). | |
| bool | count_step_ () noexcept |
| Count a step, for step(). | |
| void | check_step_ (const joint_action_type &actions) const |
| Throw unless make() was called and actions has one action per agent. | |
| template<typename T> | |
| T | option_ (const std::string &name, const T &default_value) const |
| Read a make option, or give default_value when it is missing. | |
The base of environments where several agents act at the same time.
Every step takes a joint action, one action per agent, and the environment applies them together; this is the "parallel" form of multi-agent environments that PettingZoo also uses. A turn-based game fits it too, with the agents whose turn it is not ignored.
The interface follows bitrl::envs::EnvBase: make() with options, reset() and step(). Every reset() uses the next seed, seed + n, where seed is the reset option "seed" (42 if not given) and n the number of resets since make(), so that episodes start differently but repeatably.
| ObservationType | what one agent observes |
| ActionType | what one agent does |
| typedef ActionType bitrl::envs::multi_agent::MultiAgentEnvBase< ObservationType, ActionType >::action_type |
| typedef std::vector<action_type> bitrl::envs::multi_agent::MultiAgentEnvBase< ObservationType, ActionType >::joint_action_type |
One action per agent, in the order of the agents.
| typedef ObservationType bitrl::envs::multi_agent::MultiAgentEnvBase< ObservationType, ActionType >::observation_type |
| typedef MultiAgentTimeStep<ObservationType> bitrl::envs::multi_agent::MultiAgentEnvBase< ObservationType, ActionType >::time_step_type |
|
virtualdefault |
|
inlineexplicitprotected |
|
inline |
The name of an agent, for printing.
|
protected |
Throw unless make() was called and actions has one action per agent.
|
inlinevirtual |
Release the environment; make() builds it again.
|
inlineprotectednoexcept |
Count a step, for step().
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
virtual |
Build the environment.
| version | the version of the environment |
| make_options | the options of the environment; see the derived class |
| reset_options | the options of reset(), "seed" for one |
Reimplemented in bitrl::envs::multi_agent::MultiAgentGridWorld, and bitrl::envs::multi_agent::MultiRobotNavigation.
|
inlineprotectednoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
The steps after which an episode is truncated.
|
inlinenoexcept |
|
inlinenoexcept |
The steps of the current episode so far.
|
protected |
Read a make option, or give default_value when it is missing.
|
inline |
Start a new episode with the next seed.
|
pure virtual |
Start a new episode with the given seed.
Implemented in bitrl::envs::multi_agent::MultiAgentGridWorld, and bitrl::envs::multi_agent::MultiRobotNavigation.
|
inlineprotected |
Name the agents; their number is the number of names.
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
Start counting the steps of a new episode, for reset().
|
pure virtual |
Apply one action per agent.
Implemented in bitrl::envs::multi_agent::MultiAgentGridWorld, and bitrl::envs::multi_agent::MultiRobotNavigation.
|
inlinenoexcept |
|
staticconstexpr |