feat: Implement World Architect
This commit is contained in:
@@ -5,6 +5,8 @@ from pathlib import Path
|
||||
|
||||
from entities import Entity, Player
|
||||
from memory import MemoryEntry
|
||||
from time_utils import WorldClock
|
||||
from world_architect import WorldState
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -13,6 +15,7 @@ class Scenario:
|
||||
metadata: dict
|
||||
entities: dict
|
||||
player_id: str | None = None
|
||||
world_state: WorldState | None = None
|
||||
|
||||
|
||||
def load_scenario(path: Path) -> Scenario:
|
||||
@@ -68,7 +71,37 @@ def load_scenario(path: Path) -> Scenario:
|
||||
entities[entity_id] = entity
|
||||
|
||||
logger.info("Loaded %s entities from scenario.", len(entities))
|
||||
return Scenario(metadata=metadata, entities=entities, player_id=player_id)
|
||||
|
||||
# Initialize world state
|
||||
world_state = WorldState()
|
||||
world_state.world_clock = WorldClock.from_time_str(world_time)
|
||||
|
||||
# Populate world state with entity data
|
||||
for entity_id, entity in entities.items():
|
||||
world_state.entities[entity_id] = {
|
||||
"name": entity.name,
|
||||
"location": location,
|
||||
"health": 100,
|
||||
"status": "calm",
|
||||
"mood": entity.current_mood,
|
||||
}
|
||||
|
||||
# Add location to world state
|
||||
world_state.locations[location.lower().replace(" ", "_")] = {
|
||||
"name": location,
|
||||
"description": f"The {location}",
|
||||
"occupants": len(entities),
|
||||
"visibility": "clear",
|
||||
}
|
||||
|
||||
logger.info("Initialized WorldState for scenario")
|
||||
|
||||
return Scenario(
|
||||
metadata=metadata,
|
||||
entities=entities,
|
||||
player_id=player_id,
|
||||
world_state=world_state,
|
||||
)
|
||||
|
||||
|
||||
def dump_scenario(scenario: Scenario) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user