+
+ def regenerate_chunk_from_map_stats(map_):
+ import math
+ max_stat = self.max_map_awakeness
+ for t_type in map_.stats:
+ stat = map_.stats[t_type]
+ to_create = stat['population'] // max_stat
+ mod_created = int(self.rand.randint(0, max_stat - 1) <
+ (stat['population'] % max_stat))
+ to_create = (stat['population'] // max_stat) + mod_created
+ if to_create == 0:
+ continue
+ average_health = None
+ if stat['health'] > 0:
+ average_health = math.ceil(stat['health'] /
+ stat['population'])
+ for i in range(to_create):
+ t = self.add_thing_at_random(map_pos, t_type)
+ if average_health:
+ t.health = average_health
+