Skip to content

Commit

Permalink
MPE fix agent dynamics (#970)
Browse files Browse the repository at this point in the history
Co-authored-by: vateseif <vateseif@gmail.com>
  • Loading branch information
elliottower and vateseif authored May 15, 2023
1 parent 9c0ce69 commit a6b5862
Show file tree
Hide file tree
Showing 24 changed files with 125 additions and 125 deletions.
6 changes: 3 additions & 3 deletions docs/environments/mpe.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ pip install pettingzoo[mpe]
### Usage
To launch a [Simple Tag](https://pettingzoo.farama.org/environments/mpe/simple_tag/) environment with random agents:

```python
from pettingzoo.mpe import simple_tag_v2
env = simple_tag_v2.env(render_mode='human')
``` python
from pettingzoo.mpe import simple_tag_v3
env = simple_tag_v3.env(render_mode='human')

env.reset()
for agent in env.agent_iter():
Expand Down
2 changes: 1 addition & 1 deletion pettingzoo/mpe/_mpe_utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def integrate_state(self, p_force):
for i, entity in enumerate(self.entities):
if not entity.movable:
continue
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
Expand All @@ -184,7 +185,6 @@ def integrate_state(self, p_force):
)
* entity.max_speed
)
entity.state.p_pos += entity.state.p_vel * self.dt

def update_agent_state(self, agent):
# set communication state (directly for now)
Expand Down
6 changes: 3 additions & 3 deletions pettingzoo/mpe/simple/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_v2` |
| Import | `from pettingzoo.mpe import simple_v3` |
|--------------------|----------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand All @@ -31,7 +31,7 @@
### Arguments
``` python
simple_v2.env(max_cycles=25, continuous_actions=False)
simple_v3.env(max_cycles=25, continuous_actions=False)
```
Expand Down Expand Up @@ -69,7 +69,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None):
max_cycles=max_cycles,
continuous_actions=continuous_actions,
)
self.metadata["name"] = "simple_v2"
self.metadata["name"] = "simple_v3"


env = make_env(raw_env)
Expand Down
6 changes: 3 additions & 3 deletions pettingzoo/mpe/simple_adversary/simple_adversary.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_adversary_v2` |
| Import | `from pettingzoo.mpe import simple_adversary_v3` |
|--------------------|--------------------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand Down Expand Up @@ -39,7 +39,7 @@
### Arguments
``` python
simple_adversary_v2.env(N=2, max_cycles=25, continuous_actions=False)
simple_adversary_v3.env(N=2, max_cycles=25, continuous_actions=False)
```
Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(self, N=2, max_cycles=25, continuous_actions=False, render_mode=Non
max_cycles=max_cycles,
continuous_actions=continuous_actions,
)
self.metadata["name"] = "simple_adversary_v2"
self.metadata["name"] = "simple_adversary_v3"


env = make_env(raw_env)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions pettingzoo/mpe/simple_crypto/simple_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_crypto_v2` |
| Import | `from pettingzoo.mpe import simple_crypto_v3` |
|--------------------|-----------------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand Down Expand Up @@ -45,7 +45,7 @@
### Arguments
``` python
simple_crypto_v2.env(max_cycles=25, continuous_actions=False)
simple_crypto_v3.env(max_cycles=25, continuous_actions=False)
```
Expand Down Expand Up @@ -90,7 +90,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None):
max_cycles=max_cycles,
continuous_actions=continuous_actions,
)
self.metadata["name"] = "simple_crypto_v2"
self.metadata["name"] = "simple_crypto_v3"


env = make_env(raw_env)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions pettingzoo/mpe/simple_push/simple_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_push_v2` |
| Import | `from pettingzoo.mpe import simple_push_v3` |
|--------------------|---------------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand Down Expand Up @@ -38,7 +38,7 @@
### Arguments
``` python
simple_push_v2.env(max_cycles=25, continuous_actions=False)
simple_push_v3.env(max_cycles=25, continuous_actions=False)
```
Expand Down Expand Up @@ -74,7 +74,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None):
max_cycles=max_cycles,
continuous_actions=continuous_actions,
)
self.metadata["name"] = "simple_push_v2"
self.metadata["name"] = "simple_push_v3"


env = make_env(raw_env)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions pettingzoo/mpe/simple_reference/simple_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_reference_v2` |
| Import | `from pettingzoo.mpe import simple_reference_v3` |
|--------------------|--------------------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand Down Expand Up @@ -40,7 +40,7 @@
``` python
simple_reference_v2.env(local_ratio=0.5, max_cycles=25, continuous_actions=False)
simple_reference_v3.env(local_ratio=0.5, max_cycles=25, continuous_actions=False)
```
Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(
continuous_actions=continuous_actions,
local_ratio=local_ratio,
)
self.metadata["name"] = "simple_reference_v2"
self.metadata["name"] = "simple_reference_v3"


env = make_env(raw_env)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_speaker_listener_v3` |
| Import | `from pettingzoo.mpe import simple_speaker_listener_v4` |
|----------------------|---------------------------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand Down Expand Up @@ -37,7 +37,7 @@
### Arguments
``` python
simple_speaker_listener_v2.env(max_cycles=25, continuous_actions=False)
simple_speaker_listener_v4.env(max_cycles=25, continuous_actions=False)
```
Expand Down Expand Up @@ -75,7 +75,7 @@ def __init__(self, max_cycles=25, continuous_actions=False, render_mode=None):
max_cycles=max_cycles,
continuous_actions=continuous_actions,
)
self.metadata["name"] = "simple_speaker_listener_v3"
self.metadata["name"] = "simple_speaker_listener_v4"


env = make_env(raw_env)
Expand Down
6 changes: 3 additions & 3 deletions pettingzoo/mpe/simple_spread/simple_spread.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_spread_v2` |
| Import | `from pettingzoo.mpe import simple_spread_v3` |
|----------------------|-----------------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand All @@ -36,7 +36,7 @@
### Arguments
``` python
simple_spread_v2.env(N=3, local_ratio=0.5, max_cycles=25, continuous_actions=False)
simple_spread_v3.env(N=3, local_ratio=0.5, max_cycles=25, continuous_actions=False)
```
Expand Down Expand Up @@ -91,7 +91,7 @@ def __init__(
continuous_actions=continuous_actions,
local_ratio=local_ratio,
)
self.metadata["name"] = "simple_spread_v2"
self.metadata["name"] = "simple_spread_v3"


env = make_env(raw_env)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions pettingzoo/mpe/simple_tag/simple_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_tag_v2` |
| Import | `from pettingzoo.mpe import simple_tag_v3` |
|--------------------|------------------------------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand Down Expand Up @@ -45,7 +45,7 @@ def bound(x):
### Arguments
``` python
simple_tag_v2.env(num_good=1, num_adversaries=3, num_obstacles=2, max_cycles=25, continuous_actions=False)
simple_tag_v3.env(num_good=1, num_adversaries=3, num_obstacles=2, max_cycles=25, continuous_actions=False)
```
Expand Down Expand Up @@ -100,7 +100,7 @@ def __init__(
max_cycles=max_cycles,
continuous_actions=continuous_actions,
)
self.metadata["name"] = "simple_tag_v2"
self.metadata["name"] = "simple_tag_v3"


env = make_env(raw_env)
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pettingzoo/mpe/simple_world_comm/simple_world_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This environment is part of the <a href='..'>MPE environments</a>. Please read that page first for general information.
| Import | `from pettingzoo.mpe import simple_world_comm_v2` |
| Import | `from pettingzoo.mpe import simple_world_comm_v3` |
|--------------------|-------------------------------------------------------------------------------------|
| Actions | Discrete/Continuous |
| Parallel API | Yes |
Expand Down Expand Up @@ -117,7 +117,7 @@ def __init__(
max_cycles=max_cycles,
continuous_actions=continuous_actions,
)
self.metadata["name"] = "simple_world_comm_v2"
self.metadata["name"] = "simple_world_comm_v3"


env = make_env(raw_env)
Expand Down
File renamed without changes.
60 changes: 30 additions & 30 deletions pettingzoo/test/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
]
env_graphical_obs = ["knights_archers_zombies_v10"]
env_diff_obs_shapes = [
"simple_adversary_v2",
"simple_world_comm_v2",
"simple_tag_v2",
"simple_adversary_v3",
"simple_world_comm_v3",
"simple_tag_v3",
"knights_archers_zombies_v10",
"simple_push_v2",
"simple_speaker_listener_v3",
"simple_crypto_v2",
"simple_push_v3",
"simple_speaker_listener_v4",
"simple_crypto_v3",
]
env_all_zeros_obs = ["knights_archers_zombies_v10"]
env_obs_space = [
Expand All @@ -54,36 +54,36 @@
"gin_rummy_v4",
]
env_diff_agent_obs_size = [
"simple_adversary_v2",
"simple_world_comm_v2",
"simple_tag_v2",
"simple_crypto_v2",
"simple_push_v2",
"simple_speaker_listener_v3",
"simple_adversary_v3",
"simple_world_comm_v3",
"simple_tag_v3",
"simple_crypto_v3",
"simple_push_v3",
"simple_speaker_listener_v4",
]
env_pos_inf_obs = [
"simple_adversary_v2",
"simple_reference_v2",
"simple_spread_v2",
"simple_tag_v2",
"simple_world_comm_v2",
"simple_adversary_v3",
"simple_reference_v3",
"simple_spread_v3",
"simple_tag_v3",
"simple_world_comm_v3",
"multiwalker_v9",
"simple_crypto_v2",
"simple_push_v2",
"simple_speaker_listener_v3",
"simple_v2",
"simple_crypto_v3",
"simple_push_v3",
"simple_speaker_listener_v4",
"simple_v3",
]
env_neg_inf_obs = [
"simple_adversary_v2",
"simple_reference_v2",
"simple_spread_v2",
"simple_tag_v2",
"simple_world_comm_v2",
"simple_adversary_v3",
"simple_reference_v3",
"simple_spread_v3",
"simple_tag_v3",
"simple_world_comm_v3",
"multiwalker_v9",
"simple_crypto_v2",
"simple_push_v2",
"simple_speaker_listener_v3",
"simple_v2",
"simple_crypto_v3",
"simple_push_v3",
"simple_speaker_listener_v4",
"simple_v3",
]


Expand Down
36 changes: 18 additions & 18 deletions pettingzoo/test/state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
import numpy as np

env_pos_inf_state = [
"simple_adversary_v2",
"simple_reference_v2",
"simple_spread_v2",
"simple_tag_v2",
"simple_world_comm_v2",
"simple_crypto_v2",
"simple_push_v2",
"simple_speaker_listener_v3",
"simple_v2",
"simple_adversary_v3",
"simple_reference_v3",
"simple_spread_v3",
"simple_tag_v3",
"simple_world_comm_v3",
"simple_crypto_v3",
"simple_push_v3",
"simple_speaker_listener_v4",
"simple_v3",
]
env_neg_inf_state = [
"simple_adversary_v2",
"simple_reference_v2",
"simple_spread_v2",
"simple_tag_v2",
"simple_world_comm_v2",
"simple_crypto_v2",
"simple_push_v2",
"simple_speaker_listener_v3",
"simple_v2",
"simple_adversary_v3",
"simple_reference_v3",
"simple_spread_v3",
"simple_tag_v3",
"simple_world_comm_v3",
"simple_crypto_v3",
"simple_push_v3",
"simple_speaker_listener_v4",
"simple_v3",
]


Expand Down
Loading

0 comments on commit a6b5862

Please sign in to comment.