1#ifndef MULTI_AGENT_GRID_WORLD_H
2#define MULTI_AGENT_GRID_WORLD_H
9#include <unordered_map>
88 const std::unordered_map<std::string, std::any> &
make_options,
89 const std::unordered_map<std::string, std::any> &reset_options)
override;
122 return cell.first * n_cols_ + cell.second;
125 const std::vector<cell_type> &
positions() const noexcept {
return positions_; }
127 const std::vector<cell_type> &
goals() const noexcept {
return goals_; }
145 std::vector<std::string> layout_;
146 std::vector<cell_type> starts_;
147 std::vector<cell_type> goals_;
148 std::vector<cell_type> positions_;
149 std::vector<bool> dones_;
155 bool shared_reward_{
false};
156 real_t step_reward_{-0.05};
158 real_t collision_reward_{-0.5};
std::string version() const noexcept
Definition multi_agent_env_base.h:90
MultiAgentEnvBase(const std::string &name)
Definition multi_agent_env_base.h:110
const std::unordered_map< std::string, std::any > & make_options() const noexcept
Definition multi_agent_env_base.h:104
time_step_type reset()
Definition multi_agent_env_base.h:62
std::vector< action_type > joint_action_type
Definition multi_agent_env_base.h:43
MultiAgentTimeStep< uint_t > time_step_type
Definition multi_agent_env_base.h:38
std::string render() const
The map with the agents in upper case and their goals in lower case.
time_step_type step(const joint_action_type &actions) override
Apply one action per agent.
uint_t n_collisions() const noexcept
The moves cancelled by collisions in the current episode.
Definition multi_agent_grid_world.h:132
uint_t cell_index(const cell_type &cell) const noexcept
The index of a cell, row * n_cols() + col.
Definition multi_agent_grid_world.h:120
base_type::joint_action_type joint_action_type
Definition multi_agent_grid_world.h:69
MultiAgentEnvBase< uint_t, uint_t > base_type
Definition multi_agent_grid_world.h:67
const std::vector< cell_type > & goals() const noexcept
Definition multi_agent_grid_world.h:127
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) override
Build the environment.
GridObservation observation_type() const noexcept
Definition multi_agent_grid_world.h:110
base_type::time_step_type time_step_type
Definition multi_agent_grid_world.h:68
uint_t n_cells() const noexcept
Definition multi_agent_grid_world.h:101
static std::vector< std::string > default_layout()
Two rooms joined by a corridor one cell wide. Agent A goes from the top left to the bottom right,...
std::pair< uint_t, uint_t > cell_type
A cell: row, column.
Definition multi_agent_grid_world.h:74
uint_t n_states() const noexcept
The number of observations of one agent.
Definition multi_agent_grid_world.h:106
uint_t n_cols() const noexcept
Definition multi_agent_grid_world.h:99
bool is_free(const cell_type &cell) const noexcept
Whether a cell is inside the map and not a wall.
uint_t n_rows() const noexcept
Definition multi_agent_grid_world.h:97
uint_t n_actions() const noexcept
Definition multi_agent_grid_world.h:108
static constexpr uint_t N_ACTIONS
Definition multi_agent_grid_world.h:76
const std::vector< cell_type > & positions() const noexcept
Definition multi_agent_grid_world.h:125
time_step_type reset(uint_t seed) override
Start a new episode with the given seed.
Definition distributed_agent_env.h:19
GridMove
The moves of an agent of MultiAgentGridWorld.
Definition multi_agent_grid_world.h:22
@ RIGHT
Definition multi_agent_grid_world.h:25
@ LEFT
Definition multi_agent_grid_world.h:27
@ STAY
Definition multi_agent_grid_world.h:23
@ DOWN
Definition multi_agent_grid_world.h:26
@ UP
Definition multi_agent_grid_world.h:24
GridObservation
What an agent of MultiAgentGridWorld observes.
Definition multi_agent_grid_world.h:34
@ JOINT_POSITIONS
its own cell and the cells of the others
Definition multi_agent_grid_world.h:36
@ OWN_POSITION
its own cell only
Definition multi_agent_grid_world.h:35
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
TimeStepTp
The TimeStepTp enum.
Definition time_step_type.h:15
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20