1
0
Fork 0

normalize yaml extensions

This commit is contained in:
Sean Sube 2024-06-22 17:54:54 -05:00
parent 205d6923b3
commit c78de18377
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
23 changed files with 137 additions and 99 deletions

View File

@ -73,14 +73,15 @@ TaleWeave AI has in-game actions for:
TaleWeave AI has game systems for:
| Core | Life Sim | RPG | Environment |
| -------- | --------------- | ------ | ----------- |
| Acting | Hunger & Thirst | Health | Humidity |
| Planning | Hygiene | Quests | Temperature |
| Summary | Mood | | Time of day |
| | Sleeping | | Weather |
| Core | Life Sim | RPG | Environment | Generic |
| -------- | --------------- | ------ | ----------- | ------- |
| Acting | Hunger & Thirst | Health | Humidity | Logic |
| Planning | Hygiene | Quests | Temperature | |
| Summary | Mood | | Time of day | |
| | Sleeping | | Weather | |
1. The core summary system provides character with a summary of actions taken by other characters in between turns.
2. The generic systems are driven by data files and can be used to implement new systems without writing any code.
All of the game systems are optional, including the core systems, so you can configure a world where characters only
plan and never act, or vice versa.

View File

@ -264,7 +264,7 @@ def main():
logger.info(f"loading extra actions from {action_name}")
action_group, module_actions = load_plugin(action_name)
logger.info(
f"loaded extra actions to group '{action_group}': {[action.__name__ for action in module_actions]}"
f"added actions to group '{action_group}': {[action.__name__ for action in module_actions]}"
)
# set up the game systems
@ -274,17 +274,18 @@ def main():
# load extra systems from plugins
for system_name in args.systems or []:
logger.info(f"loading extra systems from {system_name}")
logger.info(f"loading systems from {system_name}")
module_systems = load_plugin(system_name)
logger.info(f"loaded extra systems: {module_systems}")
logger.info(f"loaded game systems: {module_systems}")
systems.extend(module_systems)
# make sure the server system runs after any updates
if args.server:
from taleweave.server.websocket import server_system
systems.append(GameSystem(name="server", simulate=server_system))
systems.append(GameSystem(name="websocket_server", simulate=server_system))
logger.info(f"running with {len(systems)} game systems: {systems}")
set_game_systems(systems)
# load or generate the world

View File

@ -1,40 +0,0 @@
rules:
# wet/dry logic
- group: environment-moisture
match:
type: character
wet: true
chance: 0.1
set:
wet: false
- group: environment-moisture
match:
type: character
wet: true
temperature: hot
chance: 0.2
set:
wet: false
- group: environment-temperature
match:
type: room
temperature: hot
chance: 0.2
trigger: [taleweave.systems.sim.environment_triggers:hot_room]
- group: environment-temperature
match:
type: room
temperature: cold
chance: 0.2
trigger: [taleweave.systems.sim.environment_triggers:cold_room]
labels:
- match:
type: character
wet: true
backstory: You are soaking wet.
description: They are soaking wet and dripping water.
# false intentionally omitted

View File

@ -0,0 +1,26 @@
rules:
# wet/dry logic
- group: environment.moisture
match:
type: character
wet: true
chance: 0.1
set:
wet: false
- group: environment.moisture
match:
type: character
wet: true
temperature: hot
chance: 0.2
set:
wet: false
labels:
- match:
type: character
wet: true
backstory: You are soaking wet.
description: They are soaking wet and dripping water.
# false intentionally omitted

View File

@ -1,35 +1,17 @@
rules:
# wet/dry logic
- group: environment-moisture
match:
type: character
wet: true
chance: 0.1
set:
wet: false
- group: environment-moisture
match:
type: character
wet: true
temperature: hot
chance: 0.2
set:
wet: false
- group: environment-temperature
- group: environment.temperature
match:
type: room
temperature: hot
chance: 0.2
trigger: [taleweave.systems.sim.environment_triggers:hot_room]
trigger: [taleweave.systems.environment.temperature.triggers:hot_room]
- group: environment-temperature
- group: environment.temperature
match:
type: room
temperature: cold
chance: 0.2
trigger: [taleweave.systems.sim.environment_triggers:cold_room]
trigger: [taleweave.systems.environment.temperature.triggers:cold_room]
labels:
- match:

View File

@ -1,6 +1,6 @@
rules:
# weather logic
- group: weather
- group: environment.weather
match:
type: room
environment: outdoor
@ -9,7 +9,7 @@ rules:
set:
weather: clouds
- group: weather
- group: environment.weather
match:
type: room
environment: outdoor
@ -18,7 +18,7 @@ rules:
set:
weather: rain
- group: weather
- group: environment.weather
match:
type: room
environment: outdoor
@ -27,7 +27,7 @@ rules:
set:
weather: clear
- group: weather
- group: environment.weather
match:
type: room
environment: outdoor
@ -37,7 +37,7 @@ rules:
weather: clear
# weather initial state
- group: weather
- group: environment.weather
match:
type: room
environment: outdoor

View File

@ -187,7 +187,7 @@ def load_logic(filename: str, name_prefix: str = "logic") -> GameSystem:
)
logic_triggers[trigger] = get_plugin_function(function_name)
logger.info("initialized logic system")
logger.info("initialized logic system with %d rules", len(logic_rules.rules))
system_format = wraps(format_logic)(partial(format_logic, rules=logic_rules))
system_initialize = wraps(update_logic)(
partial(update_logic, turn=0, rules=logic_rules, triggers=logic_triggers)

View File

@ -0,0 +1,2 @@
rules: []
labels: []

View File

@ -0,0 +1,33 @@
rules:
- group: rpg.health
match:
type: character
rule: |
"health" in attributes and attributes&.health <= 0
set:
active: false
dead: true
- group: rpg.health
match:
type: character
rule: |
"bleeding" in attributes and attributes&.bleeding > 0
chance: 0.5
trigger: [taleweave.systems.rpg.health.triggers:character_bleeding]
labels:
- match:
type: character
dead: true
backstory: You are dead.
description: They are dead.
- match:
type: character
bleeding: true
backstory: You are bleeding.
description: They are bleeding.
- match:
type: room
bloody: true
description: The room is covered in blood.

View File

@ -0,0 +1,33 @@
from logging import getLogger
from random import randint
from taleweave.context import get_current_world
from taleweave.models.entity import Character, WorldEntity
from taleweave.utils.attribute import subtract_attribute
from taleweave.utils.search import find_containing_room
logger = getLogger(__name__)
def character_bleeding(entity: WorldEntity) -> None:
world = get_current_world()
if not world:
raise ValueError("no world found")
if not isinstance(entity, Character):
raise ValueError("bleeding entity must be a character")
# remove bleeding from health, then reduce bleeding
amount = int(entity.attributes.get("bleeding", 0))
subtract_attribute(entity.attributes, "health", amount)
if amount > 0 and randint(0, 1):
subtract_attribute(entity.attributes, "bleeding", 1)
# leave blood in the room
room = find_containing_room(world, entity)
if room:
room.attributes["bloody"] = True
logger.info(f"{entity.name} bleeds in {room.name}")
else:
logger.warning(f"{entity.name} not found in any room")

View File

@ -3,7 +3,7 @@ from os import path
from taleweave.systems.generic.logic import load_logic
from .hunger.actions import action_cook, action_eat
from .hygiene.hygiene_actions import action_wash
from .hygiene.actions import action_wash
from .sleeping.actions import action_sleep

View File

@ -1,6 +1,6 @@
rules:
# cooking logic
- group: cooking
- group: sim.cooking
match:
type: item
edible: true
@ -9,7 +9,7 @@ rules:
set:
spoiled: true
- group: cooking
- group: sim.cooking
match:
type: item
edible: true
@ -19,7 +19,7 @@ rules:
spoiled: true
# hunger logic
- group: hunger
- group: sim.hunger
match:
type: character
hunger: full
@ -28,14 +28,14 @@ rules:
hunger: hungry
# hunger initialization
- group: hunger
- group: sim.hunger
rule: |
"hunger" not in attributes
set:
hunger: full
# thirst logic
- group: thirst
- group: sim.thirst
match:
type: character
thirst: hydrated
@ -44,7 +44,7 @@ rules:
thirst: thirsty
# thirst initialization
- group: thirst
- group: sim.thirst
rule: |
"thirst" not in attributes
set:

View File

@ -1,6 +1,6 @@
rules:
# mood logic
- group: mood
- group: sim.mood
match:
type: character
mood: happy
@ -8,7 +8,7 @@ rules:
set:
mood: sad
- group: mood
- group: sim.mood
match:
type: character
mood: happy
@ -16,7 +16,7 @@ rules:
set:
mood: neutral
- group: mood
- group: sim.mood
match:
type: character
mood: angry
@ -24,7 +24,7 @@ rules:
set:
mood: neutral
- group: mood
- group: sim.mood
match:
type: character
mood: neutral
@ -32,7 +32,7 @@ rules:
set:
mood: happy
- group: mood
- group: sim.mood
match:
type: character
mood: neutral
@ -40,7 +40,7 @@ rules:
set:
mood: sad
- group: mood
- group: sim.mood
match:
type: character
mood: sad
@ -48,7 +48,7 @@ rules:
set:
mood: angry
- group: mood
- group: sim.mood
match:
type: character
mood: sad
@ -57,7 +57,7 @@ rules:
mood: neutral
# mood interactions with other systems
- group: mood
- group: sim.mood
match:
type: character
mood: sad
@ -66,7 +66,7 @@ rules:
set:
sleep: tired
- group: mood
- group: sim.mood
match:
type: character
hunger: hungry
@ -74,7 +74,7 @@ rules:
set:
mood: angry
- group: mood
- group: sim.mood
match:
type: character
mood: angry
@ -83,7 +83,7 @@ rules:
set:
mood: neutral
- group: mood
- group: sim.mood
match:
type: character
mood: neutral
@ -92,7 +92,7 @@ rules:
set:
mood: happy
- group: mood
- group: sim.mood
match:
type: character
mood: happy
@ -101,7 +101,7 @@ rules:
set:
mood: neutral
- group: mood
- group: sim.mood
match:
type: character
mood: neutral
@ -111,7 +111,7 @@ rules:
mood: sad
# mood initialization
- group: mood
- group: sim.mood
rule: |
"mood" not in attributes
set: