make core systems optional, format logic labels as templates
This commit is contained in:
parent
c78de18377
commit
d76bcf0b8a
|
@ -5,5 +5,6 @@ venv/
|
||||||
client/node_modules/
|
client/node_modules/
|
||||||
client/out/
|
client/out/
|
||||||
taleweave/custom_*
|
taleweave/custom_*
|
||||||
|
taleweave/systems/custom/
|
||||||
.coverage
|
.coverage
|
||||||
coverage.*
|
coverage.*
|
||||||
|
|
|
@ -75,7 +75,7 @@ TaleWeave AI has game systems for:
|
||||||
|
|
||||||
| Core | Life Sim | RPG | Environment | Generic |
|
| Core | Life Sim | RPG | Environment | Generic |
|
||||||
| -------- | --------------- | ------ | ----------- | ------- |
|
| -------- | --------------- | ------ | ----------- | ------- |
|
||||||
| Acting | Hunger & Thirst | Health | Humidity | Logic |
|
| Acting | Hunger & Thirst | Health | Moisture | Logic |
|
||||||
| Planning | Hygiene | Quests | Temperature | |
|
| Planning | Hygiene | Quests | Temperature | |
|
||||||
| Summary | Mood | | Time of day | |
|
| Summary | Mood | | Time of day | |
|
||||||
| | Sleeping | | Weather | |
|
| | Sleeping | | Weather | |
|
||||||
|
|
|
@ -60,8 +60,6 @@ if True:
|
||||||
from taleweave.models.prompt import PromptLibrary
|
from taleweave.models.prompt import PromptLibrary
|
||||||
from taleweave.plugins import load_plugin
|
from taleweave.plugins import load_plugin
|
||||||
from taleweave.state import save_world_state
|
from taleweave.state import save_world_state
|
||||||
from taleweave.systems.core.action import init_action
|
|
||||||
from taleweave.systems.core.planning import init_planning
|
|
||||||
|
|
||||||
|
|
||||||
def int_or_inf(value: str) -> float | int:
|
def int_or_inf(value: str) -> float | int:
|
||||||
|
@ -269,10 +267,6 @@ def main():
|
||||||
|
|
||||||
# set up the game systems
|
# set up the game systems
|
||||||
systems: List[GameSystem] = []
|
systems: List[GameSystem] = []
|
||||||
systems.extend(init_planning())
|
|
||||||
systems.extend(init_action())
|
|
||||||
|
|
||||||
# load extra systems from plugins
|
|
||||||
for system_name in args.systems or []:
|
for system_name in args.systems or []:
|
||||||
logger.info(f"loading systems from {system_name}")
|
logger.info(f"loading systems from {system_name}")
|
||||||
module_systems = load_plugin(system_name)
|
module_systems = load_plugin(system_name)
|
||||||
|
|
|
@ -195,7 +195,7 @@ def simulate_action(world: World, turn: int, data: Any | None = None):
|
||||||
logger.exception(f"error during action for character {character.name}")
|
logger.exception(f"error during action for character {character.name}")
|
||||||
|
|
||||||
|
|
||||||
def init_action():
|
def init():
|
||||||
return [
|
return [
|
||||||
GameSystem(
|
GameSystem(
|
||||||
ACTION_SYSTEM_NAME, initialize=initialize_action, simulate=simulate_action
|
ACTION_SYSTEM_NAME, initialize=initialize_action, simulate=simulate_action
|
||||||
|
|
|
@ -191,7 +191,7 @@ def simulate_planning(world: World, turn: int, data: Any | None = None):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def init_planning():
|
def init():
|
||||||
# TODO: add format method that renders the recent notes and upcoming events
|
# TODO: add format method that renders the recent notes and upcoming events
|
||||||
return [
|
return [
|
||||||
GameSystem(
|
GameSystem(
|
||||||
|
|
|
@ -11,6 +11,7 @@ from yaml import Loader, load
|
||||||
from taleweave.game_system import FormatPerspective, GameSystem
|
from taleweave.game_system import FormatPerspective, GameSystem
|
||||||
from taleweave.models.entity import Attributes, World, WorldEntity, dataclass
|
from taleweave.models.entity import Attributes, World, WorldEntity, dataclass
|
||||||
from taleweave.plugins import get_plugin_function
|
from taleweave.plugins import get_plugin_function
|
||||||
|
from taleweave.utils.template import format_str
|
||||||
|
|
||||||
logger = getLogger(__name__)
|
logger = getLogger(__name__)
|
||||||
|
|
||||||
|
@ -158,9 +159,11 @@ def format_logic(
|
||||||
for label in rules.labels:
|
for label in rules.labels:
|
||||||
if match_logic(entity, label):
|
if match_logic(entity, label):
|
||||||
if perspective == FormatPerspective.SECOND_PERSON and label.backstory:
|
if perspective == FormatPerspective.SECOND_PERSON and label.backstory:
|
||||||
labels.append(label.backstory)
|
backstory = format_str(label.backstory, entity=entity)
|
||||||
|
labels.append(backstory)
|
||||||
elif perspective == FormatPerspective.THIRD_PERSON and label.description:
|
elif perspective == FormatPerspective.THIRD_PERSON and label.description:
|
||||||
labels.append(label.description)
|
description = format_str(label.description, entity=entity)
|
||||||
|
labels.append(description)
|
||||||
else:
|
else:
|
||||||
logger.debug("label has no relevant description: %s", label)
|
logger.debug("label has no relevant description: %s", label)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue