fixed globalpos and 2rooms1door destination spawning

This commit is contained in:
Chanumask
2024-03-25 12:30:31 +01:00
parent ce7f5cb1ea
commit 955598a129
4 changed files with 22 additions and 9 deletions

View File

@ -39,7 +39,15 @@ Agents:
- Doors
Entities:
Destinations: { }
Destinations:
spawnrule:
SpawnDestinationsPerAgent:
coords_or_quantity:
Wolfgang:
- (6,12)
Sigmund:
- (6, 2)
Doors: { }
GlobalPositions: { }
@ -57,5 +65,5 @@ Rules:
AssignGlobalPositions: { }
# Done Conditions
MaxStepsReached:
DoneAtMaxStepsReached:
max_steps: 10

View File

@ -234,8 +234,12 @@ class AssignGlobalPositions(Rule):
:return: None
"""
super().__init__()
self.level_shape = None
def on_reset(self, state, lvl_map):
def on_init(self, state, lvl_map):
self.level_shape = lvl_map.level_shape
def on_reset(self, state):
"""
Assign global positions to agents when the environment is reset.
@ -248,7 +252,7 @@ class AssignGlobalPositions(Rule):
"""
from marl_factory_grid.environment.entity.util import GlobalPosition
for agent in state[c.AGENT]:
gp = GlobalPosition(agent, lvl_map.level_shape)
gp = GlobalPosition(agent, self.level_shape)
state[c.GLOBALPOSITIONS].add_item(gp)
return []