Farama-Foundation/PettingZoo

MPE physical dynamics of agents not coherent with original paper

vateseif opened this issue · 5 comments

I am aware that the dynamics are copied from the original repo (which is no longer supported) hence why I am creating an issue here. I believe the dynamics not to be coherent with the definition in the paper Emergence of Grounded Compositional Language in Multi-Agent Populations (Appendix: Physical State and Dynamics).

entity.state.p_pos += entity.state.p_vel * self.dt

In particular entity.state.p_pos at time $t$ should be updated with the older value of entity.state.p_vel at time $t-1$.

So the fix should move that line earlier to something like this

# integrate physical state
    def integrate_state(self, p_force):
        for i, entity in enumerate(self.entities):
            if not entity.movable:
                continue
            # p_pos at time t updated with p_vel at time t-1
            entity.state.p_pos += entity.state.p_vel * self.dt

            entity.state.p_vel = entity.state.p_vel * (1 - self.damping)
            if p_force[i] is not None:
                entity.state.p_vel += (p_force[i] / entity.mass) * self.dt
            if entity.max_speed is not None:
                speed = np.sqrt(
                    np.square(entity.state.p_vel[0]) + np.square(entity.state.p_vel[1])
                )
                if speed > entity.max_speed:
                    entity.state.p_vel = (
                        entity.state.p_vel
                        / np.sqrt(
                            np.square(entity.state.p_vel[0])
                            + np.square(entity.state.p_vel[1])
                        )
                        * entity.max_speed
                    )

Thanks for letting us know, any chance you would be willing to make a PR fixing it? Also we are planning to move the MPE environments into their own repository MPE2 and updating them/fixing bugs (and potentially adding more environments), if you are interested in helping with that we would love new contributors.

I'm in for MPE2

Great to hear, shoot me a discord message (Elliot on the farama discord)

Fixed in #970