Skip to content

Commit e28625b

Browse files
[Scenario] New football (#97)
* amend * amend * amend * amend * amend * amend * observe teammates * rendering * improved football ai * improved football ai * improved football ai * reformat * Align with main * amend * test * fixes * params * params * amend * dict obs optional * amend * rendering trick * amend * amend * minor fixes * refactor configs * amend * [BugFix] More resilient interactive_rendering.py * amend * amend * amend * amend * amend * amend * amend * amend * merge main fix * amend * amend * amend * amend * amend * red symmetric * amend * amend * value improvements * better movements * update separations * Only closest agent shoots * amend * added shooting * improved dribbling and defending * added strength params * speed optimisation * strength parameters can be tuples * amend * amend * amend * amend * amend * amend * amend * amend * amend * amend * fix hermite * fix hermite * add rendering standard deviation * add rendering ellipse * formation * rendering radius * physically different * physically different * physically different * render agent index * indices * agent color * amend * more info * randomise agent indices * amend * amend * restore example * plot rotations * param docs * docs * remove dico stuff --------- Co-authored-by: Ryan Kortvelesy <[email protected]>
1 parent b76519f commit e28625b

File tree

2 files changed

+1499
-860
lines changed

2 files changed

+1499
-860
lines changed

tests/test_scenarios/test_football.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ def setup_env(self, n_envs, **kwargs) -> None:
2424
)
2525
self.env.seed(0)
2626

27-
@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="Test needs linux")
28-
def test_ai_vs_random(self, n_envs=4, n_agents=3):
27+
@pytest.mark.skipif(
28+
sys.platform.startswith("win32"), reason="Test does not work on windows"
29+
)
30+
def test_ai_vs_random(self, n_envs=4, n_agents=3, scoring_reward=1):
2931
self.setup_env(
3032
n_red_agents=n_agents,
3133
n_blue_agents=n_agents,
3234
ai_red_agents=True,
3335
ai_blue_agents=False,
34-
dense_reward_ratio=0,
36+
dense_reward=False,
3537
n_envs=n_envs,
38+
scoring_reward=scoring_reward,
3639
)
3740
all_done = torch.full((n_envs,), False)
3841
obs = self.env.reset()
@@ -49,10 +52,10 @@ def test_ai_vs_random(self, n_envs=4, n_agents=3):
4952
total_rew[:, i] += rews[i]
5053
if dones.any():
5154
# Done envs should have exactly sum of rewards equal to num_agents
52-
actual_rew = -1 * n_agents
55+
actual_rew = -scoring_reward * n_agents
5356
assert torch.equal(
5457
total_rew[dones].sum(-1).to(torch.long),
55-
torch.full((dones.sum(),), actual_rew),
58+
torch.full((dones.sum(),), actual_rew, dtype=torch.long),
5659
)
5760
total_rew[dones] = 0
5861
all_done += dones

0 commit comments

Comments
 (0)