def forage(self, world): r, c = self._pos isForest = type(world.env.tiles[r, c].mat) in [Material.FOREST.value] if isForest and world.env.harvest(r, c): self.food.increment(5) isWater = Material.WATER.value in ai.adjacentMats(world.env, self._pos) if isWater: self.water.increment(5)
def update(self, ent, world): water = ent.resources.water water.max = self.level water.decrement() if Material.WATER.value not in ai.adjacentMats(world.env, ent.base.pos): return restore = np.floor(self.level * self.config.RESOURCERESTORE) restore = min(water.missing, restore) water.increment(restore) scale = self.config.XPSCALE self.exp += scale * restore