crafting done ?

This commit is contained in:
2023-01-13 20:07:21 +01:00
parent 7539863ace
commit 4f1044b87e
7 changed files with 554 additions and 52 deletions
+14 -8
View File
@@ -342,16 +342,11 @@ class BaseEnvironment(ABC):
self._components_dict[component_object.name] = component_object
self._shorthand_lookup[component_object.shorthand] = component_object
# Register the components with the agents
# to finish setting up their state/action spaces.
for agent in self.world.agents:
agent.register_inventory(self.resources)
agent.register_endogenous(self.endogenous)
agent.register_components(self._components)
self.world.planner.register_inventory(self.resources)
self.world.planner.register_components(self._components)
self._agent_lookup = {str(agent.idx): agent for agent in self.all_agents}
self.apply_scenario_config_to_agents()
self._completions = 0
@@ -370,6 +365,16 @@ class BaseEnvironment(ABC):
# To collate all the agents ('0', '1', ...) data during reset and step
# into a single agent with index 'a'
self.collate_agent_step_and_reset_data = collate_agent_step_and_reset_data
def apply_scenario_config_to_agents(self):
# Register the components with the agents
# to finish setting up their state/action spaces.
for agent in self.world.agents:
agent.register_inventory(self.resources)
agent.register_endogenous(self.endogenous)
agent.register_components(self._components)
self._agent_lookup = {str(agent.idx): agent for agent in self.all_agents}
self.world.apply_agent_db_to_world()
def _register_entities(self, entities):
for entity in entities:
@@ -920,6 +925,7 @@ class BaseEnvironment(ABC):
# Reset actions to that default.
for agent in self.all_agents:
agent.reset_actions()
agent.set_setup(True)
# Produce observations
obs = self._generate_observations(