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: TaleWeave AI has game systems for:
| Core | Life Sim | RPG | Environment | | Core | Life Sim | RPG | Environment | Generic |
| -------- | --------------- | ------ | ----------- | | -------- | --------------- | ------ | ----------- | ------- |
| Acting | Hunger & Thirst | Health | Humidity | | Acting | Hunger & Thirst | Health | Humidity | Logic |
| Planning | Hygiene | Quests | Temperature | | Planning | Hygiene | Quests | Temperature | |
| Summary | Mood | | Time of day | | Summary | Mood | | Time of day | |
| | Sleeping | | Weather | | | Sleeping | | Weather | |
1. The core summary system provides character with a summary of actions taken by other characters in between turns. 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 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. plan and never act, or vice versa.

View File

@ -264,7 +264,7 @@ def main():
logger.info(f"loading extra actions from {action_name}") logger.info(f"loading extra actions from {action_name}")
action_group, module_actions = load_plugin(action_name) action_group, module_actions = load_plugin(action_name)
logger.info( 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 # set up the game systems
@ -274,17 +274,18 @@ def main():
# load extra systems from plugins # load extra systems from plugins
for system_name in args.systems or []: 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) 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) systems.extend(module_systems)
# make sure the server system runs after any updates # make sure the server system runs after any updates
if args.server: if args.server:
from taleweave.server.websocket import server_system 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) set_game_systems(systems)
# load or generate the world # 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: rules:
# wet/dry logic - group: environment.temperature
- 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: match:
type: room type: room
temperature: hot temperature: hot
chance: 0.2 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: match:
type: room type: room
temperature: cold temperature: cold
chance: 0.2 chance: 0.2
trigger: [taleweave.systems.sim.environment_triggers:cold_room] trigger: [taleweave.systems.environment.temperature.triggers:cold_room]
labels: labels:
- match: - match:

View File

@ -1,6 +1,6 @@
rules: rules:
# weather logic # weather logic
- group: weather - group: environment.weather
match: match:
type: room type: room
environment: outdoor environment: outdoor
@ -9,7 +9,7 @@ rules:
set: set:
weather: clouds weather: clouds
- group: weather - group: environment.weather
match: match:
type: room type: room
environment: outdoor environment: outdoor
@ -18,7 +18,7 @@ rules:
set: set:
weather: rain weather: rain
- group: weather - group: environment.weather
match: match:
type: room type: room
environment: outdoor environment: outdoor
@ -27,7 +27,7 @@ rules:
set: set:
weather: clear weather: clear
- group: weather - group: environment.weather
match: match:
type: room type: room
environment: outdoor environment: outdoor
@ -37,7 +37,7 @@ rules:
weather: clear weather: clear
# weather initial state # weather initial state
- group: weather - group: environment.weather
match: match:
type: room type: room
environment: outdoor 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) 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_format = wraps(format_logic)(partial(format_logic, rules=logic_rules))
system_initialize = wraps(update_logic)( system_initialize = wraps(update_logic)(
partial(update_logic, turn=0, rules=logic_rules, triggers=logic_triggers) 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 taleweave.systems.generic.logic import load_logic
from .hunger.actions import action_cook, action_eat 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 from .sleeping.actions import action_sleep

View File

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

View File

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