Implementation:4thfever Cultivation world simulator make avatars
| Knowledge Sources | |
|---|---|
| Domains | Procedural_Generation, Game_Initialization |
| Last Updated | 2026-10-22 14:00 GMT |
Overview
Concrete tool for procedurally generating a group of NPC avatars with randomized attributes, sects, and relationships, provided by the Cultivation World Simulator avatar initialization system.
Description
The make_avatars function uses a `PopulationPlanner` to plan a group of N avatars with balanced sect distribution, then delegates to `AvatarFactory.build_group` to instantiate each avatar with randomized name, gender, age, race, cultivation level, sect, personas, and potential relationships.
Avatars whose rolled lifespan is already exhausted are flagged as dead-on-arrival; the init flow routes them through `handle_death`.
Usage
Import and call this function when:
- Game initialization: generating the initial NPC population
- Population injection: adding more NPCs to an existing world (though the init flow is the primary caller)
Code Reference
Source Location
- Repository: cultivation-world-simulator
- File: src/sim/avatar_init/factory.py
Signature
def make_avatars(
world: World,
count: int = 12,
current_month_stamp: MonthStamp = MonthStamp(100 * 12),
existed_sects: Optional[List[Sect]] = None,
) -> dict[str, Avatar]:
Import
from src.sim.avatar_init.factory import make_avatars
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| world | World | Yes | World instance to populate |
| count | int | No | Target NPC count (default 12) |
| current_month_stamp | MonthStamp | No | Current time stamp (default Year 100, January) |
| existed_sects | None | No | Active sects for assignment (default None) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | dict[str, Avatar] | Mapping of avatar ID to Avatar instance |
Usage Examples
Generate Initial NPC Population
from src.sim.avatar_init.factory import make_avatars
avatars = make_avatars(
world=world,
count=run_config.init_npc_num,
current_month_stamp=world.month_stamp,
existed_sects=existed_sects,
)
world.avatar_manager.avatars.update(avatars)