i think i did the converstion correct

This commit is contained in:
2023-01-12 18:33:06 +01:00
parent 03c6341b19
commit ee444cb56c
9 changed files with 131 additions and 60 deletions
+2 -2
View File
@@ -221,7 +221,7 @@ class BaseEnvironment(ABC):
# Set n_agents
self.agent_composition=agent_composition
n_agents=0
for k,v in agent_composition:
for k,v in agent_composition.items():
n_agents+=v
# Number of agents must be an integer and there must be at least 2 agents
@@ -323,7 +323,7 @@ class BaseEnvironment(ABC):
# now that we know all the entities we'll use.
self.world = World(
self.world_size,
self.n_agents,
self.agent_composition,
self.resources,
self.landmarks,
self.multi_action_mode_agents,
+4 -3
View File
@@ -381,12 +381,13 @@ class World:
self.agent_composition=agent_composition
self.n_agents=0
self._agents = []
for k,v in agent_composition:
for k,v in agent_composition.items():
self._agent_class_idx_map[k]=[]
for offset in range(v):
agent_class=agent_registry.get(k)
self._agents.append(agent_class(self.n_agents,multi_action_mode_agents=self.multi_action_mode_agents))
self._agent_class_idx_map[k].append(self.n_agents)
agent=agent_class(self.n_agents,self.multi_action_mode_agents)
self._agents.append(agent)
self._agent_class_idx_map[k].append(str(self.n_agents))
self.n_agents+=1
self.maps = Maps(world_size, self.n_agents, world_resources, world_landmarks)