Skip to content

Commit

Permalink
make core systems optional, format logic labels as templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jun 22, 2024
1 parent c78de18 commit d76bcf0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ venv/
client/node_modules/
client/out/
taleweave/custom_*
taleweave/systems/custom/
.coverage
coverage.*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TaleWeave AI has game systems for:

| Core | Life Sim | RPG | Environment | Generic |
| -------- | --------------- | ------ | ----------- | ------- |
| Acting | Hunger & Thirst | Health | Humidity | Logic |
| Acting | Hunger & Thirst | Health | Moisture | Logic |
| Planning | Hygiene | Quests | Temperature | |
| Summary | Mood | | Time of day | |
| | Sleeping | | Weather | |
Expand Down
6 changes: 0 additions & 6 deletions taleweave/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
from taleweave.models.prompt import PromptLibrary
from taleweave.plugins import load_plugin
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:
Expand Down Expand Up @@ -269,10 +267,6 @@ def shutdown_threads():

# set up the game systems
systems: List[GameSystem] = []
systems.extend(init_planning())
systems.extend(init_action())

# load extra systems from plugins
for system_name in args.systems or []:
logger.info(f"loading systems from {system_name}")
module_systems = load_plugin(system_name)
Expand Down
2 changes: 1 addition & 1 deletion taleweave/systems/core/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")


def init_action():
def init():
return [
GameSystem(
ACTION_SYSTEM_NAME, initialize=initialize_action, simulate=simulate_action
Expand Down
2 changes: 1 addition & 1 deletion taleweave/systems/core/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
return [
GameSystem(
Expand Down
7 changes: 5 additions & 2 deletions taleweave/systems/generic/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from taleweave.game_system import FormatPerspective, GameSystem
from taleweave.models.entity import Attributes, World, WorldEntity, dataclass
from taleweave.plugins import get_plugin_function
from taleweave.utils.template import format_str

logger = getLogger(__name__)

Expand Down Expand Up @@ -158,9 +159,11 @@ def format_logic(
for label in rules.labels:
if match_logic(entity, label):
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:
labels.append(label.description)
description = format_str(label.description, entity=entity)
labels.append(description)
else:
logger.debug("label has no relevant description: %s", label)

Expand Down

0 comments on commit d76bcf0

Please sign in to comment.