# Different observation space in MultiAgentEnv

**URL:** <https://discuss.ray.io/t/different-observation-space-in-multiagentenv/3207>\
**Category:** RLlib\
**Created:** [August 11, 2021, 10:14am UTC](https://discuss.ray.io/t/different-observation-space-in-multiagentenv/3207 "2021-08-11T10:14:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyle-playground](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kyle-playground/32/1392_2.png) [@kyle-playground](https://discuss.ray.io/u/kyle-playground)\
**Post date:** [August 11, 2021, 10:14am UTC](https://discuss.ray.io/t/different-observation-space-in-multiagentenv/3207/1 "2021-08-11T10:14:29Z")

</div>

Hi, I am new to rllib and recently working on custom multi-agent env, not sure how MultiAgentEnv deal with observation space mapping. I found most examples expect all agents have equal observation space which just need ob\_space = gym.space.  
If I set observation space as a Dict like below will lead to ValueError because observation is just from a single agent while observation space is a Dict.  
I am dealing with a homogeneous problem which this will not be a problem, just wondering if observation space mapping is available through MultiAgentEnv with independent learner setting.

```auto
self.observation_space = spaces.Dict({
            'agent_0': spaces.Tuple(
                [
                 spaces.Box(-np.inf, np.inf, shape=(9,), dtype=np.int64),
                 ]),   
            'agent_1': spaces.Tuple(
                [
                 spaces.Box(-np.inf, np.inf, shape=(9,), dtype=np.int64),
                 ]),
            'agent_2': spaces.Tuple(
                [
                 spaces.Box(-np.inf, np.inf, shape=(9,), dtype=np.int64),
                 ]),
        })

```

---

<div class="post-metadata">

**Author:** ![UserRLlib](https://avatars.discourse-cdn.com/v4/letter/u/b2d939/32.png) [@UserRLlib](https://discuss.ray.io/u/UserRLlib)\
**Post date:** [August 11, 2021, 2:19pm UTC](https://discuss.ray.io/t/different-observation-space-in-multiagentenv/3207/2 "2021-08-11T14:19:44Z")

</div>

Hi @kyle-playground, from my experience (if not correct, please fix me :P), actually you don’t need to define the observation/action space in the environment unless you want to check the obs/action is in the action space.

In the multi-agent RL, you need to assign policy/learner for agents, where you need to define the observation and action space for each policy.

In all, the observation and action space is actually used for the policy.

---

<div class="post-metadata">

**Author:** ![kyle-playground](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kyle-playground/32/1392_2.png) [@kyle-playground](https://discuss.ray.io/u/kyle-playground)\
**Post date:** [August 12, 2021, 2:31am UTC](https://discuss.ray.io/t/different-observation-space-in-multiagentenv/3207/3 "2021-08-12T02:31:59Z")

</div>

@UserRLlib Thanks for your reply! Now it makes sense why multiagent config requires to define observation space and action space in policy config dict.
