Skip to content

Commit d76bcf0

Browse files
committed
make core systems optional, format logic labels as templates
1 parent c78de18 commit d76bcf0

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ venv/
55
client/node_modules/
66
client/out/
77
taleweave/custom_*
8+
taleweave/systems/custom/
89
.coverage
910
coverage.*

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ TaleWeave AI has game systems for:
7575

7676
| Core | Life Sim | RPG | Environment | Generic |
7777
| -------- | --------------- | ------ | ----------- | ------- |
78-
| Acting | Hunger & Thirst | Health | Humidity | Logic |
78+
| Acting | Hunger & Thirst | Health | Moisture | Logic |
7979
| Planning | Hygiene | Quests | Temperature | |
8080
| Summary | Mood | | Time of day | |
8181
| | Sleeping | | Weather | |

taleweave/main.py

-6
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
from taleweave.models.prompt import PromptLibrary
6161
from taleweave.plugins import load_plugin
6262
from taleweave.state import save_world_state
63-
from taleweave.systems.core.action import init_action
64-
from taleweave.systems.core.planning import init_planning
6563

6664

6765
def int_or_inf(value: str) -> float | int:
@@ -269,10 +267,6 @@ def shutdown_threads():
269267

270268
# set up the game systems
271269
systems: List[GameSystem] = []
272-
systems.extend(init_planning())
273-
systems.extend(init_action())
274-
275-
# load extra systems from plugins
276270
for system_name in args.systems or []:
277271
logger.info(f"loading systems from {system_name}")
278272
module_systems = load_plugin(system_name)

taleweave/systems/core/action.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def simulate_action(world: World, turn: int, data: Any | None = None):
195195
logger.exception(f"error during action for character {character.name}")
196196

197197

198-
def init_action():
198+
def init():
199199
return [
200200
GameSystem(
201201
ACTION_SYSTEM_NAME, initialize=initialize_action, simulate=simulate_action

taleweave/systems/core/planning.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def simulate_planning(world: World, turn: int, data: Any | None = None):
191191
)
192192

193193

194-
def init_planning():
194+
def init():
195195
# TODO: add format method that renders the recent notes and upcoming events
196196
return [
197197
GameSystem(

taleweave/systems/generic/logic.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from taleweave.game_system import FormatPerspective, GameSystem
1212
from taleweave.models.entity import Attributes, World, WorldEntity, dataclass
1313
from taleweave.plugins import get_plugin_function
14+
from taleweave.utils.template import format_str
1415

1516
logger = getLogger(__name__)
1617

@@ -158,9 +159,11 @@ def format_logic(
158159
for label in rules.labels:
159160
if match_logic(entity, label):
160161
if perspective == FormatPerspective.SECOND_PERSON and label.backstory:
161-
labels.append(label.backstory)
162+
backstory = format_str(label.backstory, entity=entity)
163+
labels.append(backstory)
162164
elif perspective == FormatPerspective.THIRD_PERSON and label.description:
163-
labels.append(label.description)
165+
description = format_str(label.description, entity=entity)
166+
labels.append(description)
164167
else:
165168
logger.debug("label has no relevant description: %s", label)
166169

0 commit comments

Comments
 (0)