adjust transition probabilities for sim systems
This commit is contained in:
parent
d72c1326f1
commit
c1fc16ef81
|
@ -5,6 +5,7 @@ from .sleeping_actions import action_sleep
|
|||
from adventure.logic import init_from_file
|
||||
|
||||
LOGIC_FILES = [
|
||||
"./adventure/sim_systems/environment_logic.yaml",
|
||||
"./adventure/sim_systems/hunger_logic.yaml",
|
||||
"./adventure/sim_systems/hygiene_logic.yaml",
|
||||
"./adventure/sim_systems/mood_logic.yaml",
|
||||
|
|
|
@ -1,57 +1,64 @@
|
|||
from adventure.context import get_dungeon_master, get_agent_for_actor, get_current_context, broadcast
|
||||
from adventure.context import (
|
||||
broadcast,
|
||||
get_agent_for_actor,
|
||||
get_current_context,
|
||||
get_dungeon_master,
|
||||
)
|
||||
|
||||
|
||||
def action_attack(target: str) -> str:
|
||||
"""
|
||||
Attack a character or item in the room.
|
||||
"""
|
||||
Attack a character or item in the room.
|
||||
|
||||
Args:
|
||||
target: The name of the character or item to attack.
|
||||
"""
|
||||
Args:
|
||||
target: The name of the character or item to attack.
|
||||
"""
|
||||
|
||||
_, action_room, action_actor = get_current_context()
|
||||
_, action_room, action_actor = get_current_context()
|
||||
|
||||
# make sure the target is in the room
|
||||
target_actor = next((actor for actor in action_room.actors if actor.name == target), None)
|
||||
target_item = next((item for item in action_room.items if item.name == target), None)
|
||||
# make sure the target is in the room
|
||||
target_actor = next(
|
||||
(actor for actor in action_room.actors if actor.name == target), None
|
||||
)
|
||||
target_item = next(
|
||||
(item for item in action_room.items if item.name == target), None
|
||||
)
|
||||
|
||||
dungeon_master = get_dungeon_master()
|
||||
if target_actor:
|
||||
target_agent = get_agent_for_actor(target_actor)
|
||||
if not target_agent:
|
||||
raise ValueError(f"no agent found for actor {target_actor.name}")
|
||||
dungeon_master = get_dungeon_master()
|
||||
if target_actor:
|
||||
target_agent = get_agent_for_actor(target_actor)
|
||||
if not target_agent:
|
||||
raise ValueError(f"no agent found for actor {target_actor.name}")
|
||||
|
||||
reaction = target_agent(
|
||||
f"{action_actor.name} is attacking you in the {action_room.name}. How do you react?"
|
||||
"Respond with 'fighting', 'fleeing', or 'surrendering'."
|
||||
)
|
||||
reaction = target_agent(
|
||||
f"{action_actor.name} is attacking you in the {action_room.name}. How do you react?"
|
||||
"Respond with 'fighting', 'fleeing', or 'surrendering'."
|
||||
)
|
||||
|
||||
outcome = dungeon_master(
|
||||
f"{action_actor.name} attacks {target} in the {action_room.name}. {action_room.description}."
|
||||
f"{action_actor.description}. {target_actor.description}."
|
||||
f"{target} reacts by {reaction}. What is the outcome of the attack? Describe the result in detail."
|
||||
)
|
||||
outcome = dungeon_master(
|
||||
f"{action_actor.name} attacks {target} in the {action_room.name}. {action_room.description}."
|
||||
f"{action_actor.description}. {target_actor.description}."
|
||||
f"{target} reacts by {reaction}. What is the outcome of the attack? Describe the result in detail."
|
||||
)
|
||||
|
||||
description = (
|
||||
f"{action_actor.name} attacks the {target} in the {action_room.name}."
|
||||
f"{target} reacts by {reaction}. {outcome}"
|
||||
)
|
||||
broadcast(description)
|
||||
return description
|
||||
elif target_item:
|
||||
outcome = dungeon_master(
|
||||
f"{action_actor.name} attacks {target} in the {action_room.name}. {action_room.description}."
|
||||
f"{action_actor.description}. {target_item.description}."
|
||||
f"What is the outcome of the attack? Describe the result in detail."
|
||||
)
|
||||
description = (
|
||||
f"{action_actor.name} attacks the {target} in the {action_room.name}."
|
||||
f"{target} reacts by {reaction}. {outcome}"
|
||||
)
|
||||
broadcast(description)
|
||||
return description
|
||||
elif target_item:
|
||||
outcome = dungeon_master(
|
||||
f"{action_actor.name} attacks {target} in the {action_room.name}. {action_room.description}."
|
||||
f"{action_actor.description}. {target_item.description}."
|
||||
f"What is the outcome of the attack? Describe the result in detail."
|
||||
)
|
||||
|
||||
description = (
|
||||
f"{action_actor.name} attacks the {target} in the {action_room.name}. {outcome}"
|
||||
)
|
||||
broadcast(description)
|
||||
return description
|
||||
else:
|
||||
return f"{target} is not in the {action_room.name}."
|
||||
description = f"{action_actor.name} attacks the {target} in the {action_room.name}. {outcome}"
|
||||
broadcast(description)
|
||||
return description
|
||||
else:
|
||||
return f"{target} is not in the {action_room.name}."
|
||||
|
||||
|
||||
def action_cast(target: str, spell: str) -> str:
|
||||
|
@ -66,8 +73,12 @@ def action_cast(target: str, spell: str) -> str:
|
|||
_, action_room, action_actor = get_current_context()
|
||||
|
||||
# make sure the target is in the room
|
||||
target_actor = next((actor for actor in action_room.actors if actor.name == target), None)
|
||||
target_item = next((item for item in action_room.items if item.name == target), None)
|
||||
target_actor = next(
|
||||
(actor for actor in action_room.actors if actor.name == target), None
|
||||
)
|
||||
target_item = next(
|
||||
(item for item in action_room.items if item.name == target), None
|
||||
)
|
||||
|
||||
if not target_actor and not target_item:
|
||||
return f"{target} is not in the {action_room.name}."
|
||||
|
@ -79,8 +90,6 @@ def action_cast(target: str, spell: str) -> str:
|
|||
f"What is the outcome of the spell? Describe the result in detail."
|
||||
)
|
||||
|
||||
description = (
|
||||
f"{action_actor.name} casts {spell} on the {target} in the {action_room.name}. {outcome}"
|
||||
)
|
||||
description = f"{action_actor.name} casts {spell} on the {target} in the {action_room.name}. {outcome}"
|
||||
broadcast(description)
|
||||
return description
|
||||
|
|
|
@ -4,7 +4,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
wet: true
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
wet: false
|
||||
|
||||
|
@ -13,7 +13,7 @@ rules:
|
|||
type: actor
|
||||
wet: true
|
||||
temperature: hot
|
||||
chance: 0.5
|
||||
chance: 0.2
|
||||
set:
|
||||
wet: false
|
||||
|
||||
|
@ -21,15 +21,15 @@ rules:
|
|||
match:
|
||||
type: room
|
||||
temperature: hot
|
||||
chance: 0.5
|
||||
trigger: adventure.sim_systems.environment_triggers:hot_room
|
||||
chance: 0.2
|
||||
trigger: [adventure.sim_systems.environment_triggers:hot_room]
|
||||
|
||||
- group: environment-temperature
|
||||
match:
|
||||
type: room
|
||||
temperature: cold
|
||||
chance: 0.5
|
||||
trigger: adventure.sim_systems.environment_triggers:cold_room
|
||||
chance: 0.2
|
||||
trigger: [adventure.sim_systems.environment_triggers:cold_room]
|
||||
|
||||
labels:
|
||||
wet:
|
||||
|
|
|
@ -4,7 +4,7 @@ rules:
|
|||
type: item
|
||||
edible: true
|
||||
cooked: false
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
spoiled: true
|
||||
|
||||
|
@ -12,7 +12,7 @@ rules:
|
|||
type: item
|
||||
edible: true
|
||||
cooked: true
|
||||
chance: 0.1
|
||||
chance: 0.05
|
||||
set:
|
||||
spoiled: true
|
||||
|
||||
|
@ -20,7 +20,7 @@ rules:
|
|||
- match:
|
||||
type: actor
|
||||
hunger: full
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
hunger: hungry
|
||||
|
||||
|
@ -28,13 +28,13 @@ rules:
|
|||
- rule: |
|
||||
"hunger" not in attributes
|
||||
set:
|
||||
hunger: hungry
|
||||
hunger: full
|
||||
|
||||
# thirst logic
|
||||
- match:
|
||||
type: actor
|
||||
thirst: hydrated
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
thirst: thirsty
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from adventure.context import get_current_context, get_dungeon_master
|
||||
|
||||
|
||||
def action_wash() -> str:
|
||||
def action_wash(unused: bool) -> str:
|
||||
"""
|
||||
Wash yourself.
|
||||
"""
|
||||
|
|
|
@ -2,17 +2,23 @@ rules:
|
|||
- match:
|
||||
type: actor
|
||||
hygiene: clean
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
hygiene: dirty
|
||||
|
||||
- match:
|
||||
type: actor
|
||||
hygiene: dirty
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
hygiene: filthy
|
||||
|
||||
# initialize hygiene
|
||||
- rule: |
|
||||
"hygiene" not in attributes
|
||||
set:
|
||||
hygiene: clean
|
||||
|
||||
labels:
|
||||
hygiene:
|
||||
clean:
|
||||
|
|
|
@ -4,7 +4,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
mood: happy
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
mood: sad
|
||||
|
||||
|
@ -12,7 +12,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
mood: happy
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
mood: neutral
|
||||
|
||||
|
@ -20,7 +20,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
mood: angry
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
mood: neutral
|
||||
|
||||
|
@ -28,7 +28,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
mood: neutral
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
mood: happy
|
||||
|
||||
|
@ -36,7 +36,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
mood: neutral
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
mood: sad
|
||||
|
||||
|
@ -44,7 +44,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
mood: sad
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
mood: angry
|
||||
|
||||
|
@ -52,7 +52,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
mood: sad
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
mood: neutral
|
||||
|
||||
|
@ -62,7 +62,7 @@ rules:
|
|||
type: actor
|
||||
mood: sad
|
||||
sleep: rested
|
||||
chance: 0.5
|
||||
chance: 0.2
|
||||
set:
|
||||
sleep: tired
|
||||
|
||||
|
@ -70,7 +70,7 @@ rules:
|
|||
match:
|
||||
type: actor
|
||||
hunger: hungry
|
||||
chance: 0.5
|
||||
chance: 0.2
|
||||
set:
|
||||
mood: angry
|
||||
|
||||
|
@ -79,7 +79,7 @@ rules:
|
|||
type: actor
|
||||
mood: angry
|
||||
hunger: full
|
||||
chance: 0.5
|
||||
chance: 0.2
|
||||
set:
|
||||
mood: neutral
|
||||
|
||||
|
@ -88,7 +88,7 @@ rules:
|
|||
type: actor
|
||||
mood: neutral
|
||||
hunger: full
|
||||
chance: 0.5
|
||||
chance: 0.2
|
||||
set:
|
||||
mood: happy
|
||||
|
||||
|
@ -97,7 +97,7 @@ rules:
|
|||
type: actor
|
||||
mood: happy
|
||||
hunger: hungry
|
||||
chance: 0.5
|
||||
chance: 0.2
|
||||
set:
|
||||
mood: neutral
|
||||
|
||||
|
@ -106,7 +106,7 @@ rules:
|
|||
type: actor
|
||||
mood: neutral
|
||||
sleep: tired
|
||||
chance: 0.5
|
||||
chance: 0.2
|
||||
set:
|
||||
mood: sad
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from adventure.context import get_current_context, get_dungeon_master
|
||||
|
||||
|
||||
def action_sleep() -> str:
|
||||
def action_sleep(unused: bool) -> str:
|
||||
"""
|
||||
Sleep until you are rested.
|
||||
"""
|
||||
|
|
|
@ -3,7 +3,7 @@ rules:
|
|||
- match:
|
||||
type: actor
|
||||
sleep: rested
|
||||
chance: 0.2
|
||||
chance: 0.1
|
||||
set:
|
||||
sleep: tired
|
||||
|
||||
|
|
Loading…
Reference in New Issue