def update(self) -> None: super().update() fuel_gained = self.getResourceAvailableThisTick(self._fuel_type) energy_produced = fuel_gained * self.effectiveness_factor * self._energy_factor self._resources_produced_this_tick["energy"] = energy_produced energy_available = energy_produced + self._resources_left_over["energy"] # Attempt to "get rid" of the energy by offering it to connected sources. energy_left = self._provideResourceToOutgoingConnections( "energy", energy_available) # It's entirely possible that no energy was generated this turn, but a bunch of energy was provided (since there # was some energy left over from the last tick!) self._resources_provided_this_tick["energy"] = enforcePositive( energy_available - energy_left) # The amount of fuel we used is equal to the energy we produced. Depending on that, the generator produces heat heat_produced = fuel_gained * COMBUSTION_HEAT[ self._fuel_type] * self.temperature_efficiency self.addHeat(heat_produced) # Same thing for the water. Check how much water we have. water_available = self.getResourceAvailableThisTick("water") # And try to get rid of some water water_left = self._provideResourceToOutgoingConnections( "water", water_available) # Some amount could not be dumped, so this means we will just request less next tick. self._resources_left_over["water"] = water_left self._resources_provided_this_tick["water"] = enforcePositive( self._resources_received_this_tick["water"] - water_left) self._resources_left_over["energy"] = energy_left # Based on what happened last turn, we should potentially ask for a bit less. self._updateResourceRequiredPerTick()
def update(self) -> None: super().update() water_available = self.getResourceAvailableThisTick("water") # Technically the toilets could get damaged, but since we won't actually block players from using the toilets # when they are broken in game, I'm not going to model that in here. dirty_water_left = self._provideResourceToOutgoingConnections("dirty_water", water_available) dirty_water_provided = enforcePositive(water_available - dirty_water_left) self._resources_produced_this_tick["dirty_water"] = dirty_water_provided
def update(self) -> None: super().update() energy_gained = self.getResourceAvailableThisTick("energy") # A Computation node creates 1 energy per energy that it gets. Yay! data_available = energy_gained * self.effectiveness_factor # Attempt to get rid of the data by offering it to connected sources. data_left = self._provideResourceToOutgoingConnections("data", data_available) # Note that we don't actually store the data we have left over. Data is a "use it or lose it" resource! data_produced = enforcePositive(data_available - data_left) self._resources_produced_this_tick["data"] = data_produced # But we do give a bit of a discount heat wise! heat_produced = data_produced * self._heat_per_data_computed * self.temperature_efficiency heat_produced += data_left * self._heat_per_data_not_computed self.addHeat(heat_produced)
def update(self) -> None: super().update() # Get the resources we asked for! water_available = self.getResourceAvailableThisTick("water") energy_available = self.getResourceAvailableThisTick("energy") plant_oil_available = self.getResourceAvailableThisTick("animal_waste") medicine_produced = min(water_available, energy_available, plant_oil_available) self._resources_left_over[ "water"] = water_available - medicine_produced self._resources_left_over[ "energy"] = energy_available - medicine_produced self._resources_left_over[ "plant_oil"] = plant_oil_available - medicine_produced medicine_produced *= self.effectiveness_factor self._resources_produced_this_tick["medicine"] = medicine_produced # Attempt to get rid of the medicine medicine_left = self._provideResourceToOutgoingConnections( "medicine", medicine_produced) # if that failed, we didn't use some of the resources we got self._resources_left_over[ "water"] += medicine_left * self.inverted_effectiveness_factor self._resources_left_over[ "energy"] += medicine_left * self.inverted_effectiveness_factor self._resources_left_over[ "plant_oil"] = medicine_left * self.inverted_effectiveness_factor medicine_provided = enforcePositive(medicine_produced - medicine_left) self._resources_provided_this_tick["medicine"] = medicine_provided heat_produced = medicine_provided * self._heat_per_medicine_created * self.temperature_efficiency self.addHeat(heat_produced)
def update(self) -> None: super().update() # Get all the resources that we want fuel_available = self.getResourceAvailableThisTick("fuel") plants_available = self.getResourceAvailableThisTick("plants") water_available = self.getResourceAvailableThisTick("water") oil_produced = min(2 * fuel_available, plants_available) self._resources_left_over["plants"] = plants_available - oil_produced self._resources_left_over[ "fuel"] = fuel_available - oil_produced / self._fuel_per_plant_ratio # If the extractor gets damaged it will start to generate more waste. # For every oil that isn't produced, we generate an extra waste. # So, if it's running at 75% effiency, we will generate 0.75 oil and 1.25 waste waste_produced = oil_produced + ( oil_produced - oil_produced * self.effectiveness_factor) self._resources_produced_this_tick["waste"] = waste_produced oil_produced *= self.effectiveness_factor self._resources_produced_this_tick["plant_oil"] = oil_produced # Dump the resources produced oil_left = self._provideResourceToOutgoingConnections( "plant_oil", oil_produced) waste_left = self._provideResourceToOutgoingConnections( "waste", waste_produced) # If we couldn't dump one of our resources, we just produce less. max_resource_left = max(oil_left, waste_left) # If a part of the resources (oil or waste) could not be dumped, we have more plants/fuel left. self._resources_left_over[ "plants"] += max_resource_left * self.inverted_effectiveness_factor self._resources_left_over[ "fuel"] += max_resource_left / self._fuel_per_plant_ratio * self.inverted_effectiveness_factor fuel_used = fuel_available - self._resources_left_over["fuel"] # Burn half of the fuel used to acutaly produce something heat_produced = 0.5 * fuel_used * COMBUSTION_HEAT[ "fuel"] * self.temperature_efficiency self.addHeat(heat_produced) # Then try to dump half of the fuel that we received back again self._resources_left_over[ "fuel"] += self._provideResourceToOutgoingConnections( "fuel", 0.5 * fuel_used) # Burn *all* of the fuel that was not used to produce something (or could not be dumped!) heat_produced = self._resources_left_over["fuel"] * COMBUSTION_HEAT[ "fuel"] * self.temperature_efficiency self.addHeat(heat_produced) self._resources_left_over["fuel"] = 0 # And try to get rid of some water water_left = self._provideResourceToOutgoingConnections( "water", water_available) self._resources_left_over["water"] = water_left oil_provided = enforcePositive(oil_produced - oil_left) self._resources_provided_this_tick["plant_oil"] = oil_provided waste_provided = enforcePositive(waste_produced - waste_left) self._resources_provided_this_tick["waste"] = waste_provided
def _updateResourceRequiredPerTick(self) -> None: resources_left = self._resources_left_over["energy"] self._resources_required_per_tick[ self._fuel_type] = self._performance * enforcePositive( self._original_resources_required_per_tick[self._fuel_type] * self.health_effectiveness_factor - resources_left)
def update(self) -> None: super().update() resources_left = self._provideResourceToOutgoingConnections(self._resource_type, self._amount) self._resources_produced_this_tick[self._resource_type] = enforcePositive(self._amount - resources_left)