Skip to content

Commit ed3eb51

Browse files
authored
Merge pull request #93 from neph1/update-v0.35.1
Update v0.35.1
2 parents c9fe019 + 941a691 commit ed3eb51

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

llm_config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ ACTION_TEMPLATE: '{{"goal": reason for action, "thoughts":thoughts about perform
99
ITEM_TEMPLATE: '{{"name":"", "type":"", "short_descr":"", "level":int, "value":int}}'
1010
CREATURE_TEMPLATE: '{{"name":"", "body":"", "mass":int(kg), "hp":int, "type":"Npc or Mob", "level":int, "aggressive":bool, "unarmed_attack":One of [FISTS, CLAWS, BITE, TAIL, HOOVES, HORN, TUSKS, BEAK, TALON], "short_descr":""}}'
1111
EXIT_TEMPLATE: '{{"direction":"", "name":"name of new location", "short_descr":"exit description"}}'
12-
NPC_TEMPLATE: '{{"name":"", "sentiment":"", "race":"", "gender":"m, f, or n", "level":(int), "aggressive":bool, "description":"25 words", "appearance":"25 words"}}'
12+
NPC_TEMPLATE: '{{"name":"", "sentiment":"", "race":"", "gender":"m, f, or n", "level":(int), "aggressive":bool, "description":"25 words", "occupation":"", "appearance":"25 words"}}'
1313
LOCATION_TEMPLATE: '{{"name": "", "description":"", "exits":[], "items":[], "npcs":[], "indoors":"true or false"}}'
1414
ZONE_TEMPLATE: '{{"name":name of the room, "description": "75 words", "races":[], "items":[], "mood":"5 to -5, where 5 is extremely friendly and -5 is extremely hostile.", "level":(int)}}'
1515
DUNGEON_LOCATION_TEMPLATE: '{"index": (int), "name": "", "description": 25 words}'
16-
CHARACTER_TEMPLATE: '{"name":"", "description": "50 words", "appearance": "25 words", "personality": "50 words", "money":(int), "level":"", "gender":"m/f/n", "age":(int), "race":""}'
16+
CHARACTER_TEMPLATE: '{"name":"", "description": "50 words", "appearance": "25 words", "personality": "50 words", "money":(int), "level":"", "gender":"m/f/n", "age":(int), "race":"", "occupation":""}'
1717
FOLLOW_TEMPLATE: '{{"response":"yes or no", "reason":"50 words"}}'
1818
ITEM_TYPES: ["Weapon", "Wearable", "Health", "Money", "Trash", "Food", "Drink", "Key"]
1919
PRE_PROMPT: 'You are a creative game keeper for an interactive fiction story telling session. You craft detailed worlds and interesting characters with unique and deep personalities for the player to interact with. Do not acknowledge the task or speak directly to the user, or respond with anything besides the request..'
2020
BASE_PROMPT: '<context>{context}</context>\n[USER_START] Rewrite [{input_text}] in your own words. The information inside the <context> tags should be used to ensure it fits the story. Use about {max_words} words.'
2121
DIALOGUE_PROMPT: '<context>{context}</context>\nThe following is a conversation between {character1} and {character2}; {character2}s sentiment towards {character1}: {sentiment}. Write a single response as {character2} in third person pov, using {character2} description and other information found inside the <context> tags. If {character2} has a quest active, they will discuss it based on its status. Respond in JSON using this template: """{dialogue_template}""". [USER_START]Continue the following conversation as {character2}: {previous_conversation}'
2222
COMBAT_PROMPT: '<context>{context}</context>\nThe following is a combat scene between {attackers} and {defenders} in {location}. [USER_START] Describe the following combat result in about 150 words in vivid language, using the characters weapons and their health status: 1.0 is highest, 0.0 is lowest. Combat Result: {input_text}'
2323
PRE_JSON_PROMPT: 'Below is an instruction that describes a task, paired with an input that provides further context. Write a response in valid JSON format that appropriately completes the request.'
24-
CREATE_CHARACTER_PROMPT: '<context>{context}</context>\n[USER_START] Create a diverse character with rich personality that can be interacted with using the story context and keywords. {{quest_prompt}} Do not mention height. keywords: {keywords}. Fill in this JSON template and write nothing else: {character_template}'
24+
CREATE_CHARACTER_PROMPT: '<context>{context}</context>\n[USER_START] Create a diverse character with rich personality that can be interacted with using the story context and keywords. {{quest_prompt}} Do not mention height. Keywords: {keywords}. Fill in the blanks in this JSON template and write nothing else: {character_template}'
2525
CREATE_LOCATION_PROMPT: '<context>{context}</context>\nZone info: {zone_info}; Exit json example: {exit_template}; Npc or mob example: {npc_template}. Existing connected locations: {exit_locations}. [USER_START] Using the information supplied inside the <context> tags, describe the following location: {location_name}. {items_prompt} {spawn_prompt} Add a brief description, and one to three additional exits leading to new locations. Fill in this JSON template and do not write anything else: {location_template}. Write the response in valid JSON.'
2626
CREATE_ZONE_PROMPT: '<context>{context}</context>\n[USER_START]Using the information supplied inside the <context> tags, create an new area that can be further populated with multiple locations. It is connected in the {direction} to {zone_info}. Add a name and brief description. Choose the names of 5 creatures from the supplied list likely to find in the area. Fill in "items" with the names and types of 5 common items in the area. Fill in this JSON template and do not write anything else: {zone_template}. Write the response in valid JSON.'
2727
CREATE_DUNGEON_LOCATIONS: '<context>{context}</context>\n For the supplied list of rooms, generate a name and a one line description for each room, keeping the theme from the Zone. Use the information supplied inside the <context> tags to create a unique and interesting locations. Do not include any creatures. Depth indicates how deep in the dungeon it is. Respond with an array of locations in JSON format and do not write anything else: [{dungeon_location_template},{dungeon_location_template},...].'

tale/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ def wielding(self, weapon: Optional[Weapon]) -> None:
16021602
self.tell_others("{Actor} unwields %s." % self.__wielding.title, evoke=True, short_len=True)
16031603
self.tell("You unwield %s." % self.__wielding.title)
16041604

1605-
def set_wearable(self, wearable: Optional[Wearable], wear_location: Optional[wearable.WearLocation] = wearable.WearLocation.TORSO) -> None:
1605+
def set_wearable(self, wearable: Optional[Wearable], wear_location: Optional[wearable.WearLocation] = None) -> None:
16061606
""" Wear an item if item is not None, else unwear location"""
16071607
if wearable:
16081608
loc = wear_location if wear_location else wearable.wear_location

tale/equip_npcs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,34 @@ def equip_npc(npc: LivingNpc, world_items: list[dict], setting: str = 'fantasy')
2828
weapon = _get_item_by_name_or_random('Sword', one_handed)
2929
if weapon:
3030
npc.insert(load_item(weapon), npc)
31+
npc.wielding = npc.locate_item(weapon['name'])[0]
3132
else:
3233
weapon = _get_item_by_name_or_random('Spear', two_handed)
3334
if weapon:
3435
npc.insert(load_item(weapon), npc)
36+
npc.wielding = npc.locate_item(weapon['name'])[0]
3537
if random.random() > 0.5:
3638
helmet = wearable.random_wearable_for_body_part(WearLocation.HEAD, setting, armor_only=True)
3739
if helmet:
3840
npc.insert(load_item(helmet), npc)
41+
npc.set_wearable(npc.locate_item(helmet['name'])[0], wearable.WearLocation.HEAD)
3942
if random.random() > 0.5:
4043
torso = wearable.random_wearable_for_body_part(WearLocation.TORSO, setting, armor_only=True)
4144
if torso:
4245
npc.insert(load_item(torso), npc)
46+
npc.set_wearable(npc.locate_item(torso['name'])[0], wearable.WearLocation.TORSO)
4347
return
4448
if occupation in ['archer', 'ranger', 'hunter', 'marksman']: # Archer
4549
weapon = _get_item_by_name_or_random('Bow', ranged.values)
4650
if weapon:
4751
npc.insert(load_item(weapon), npc)
52+
npc.wielding = npc.locate_item(weapon['name'])[0]
4853
return
4954
if occupation in ['mage', 'sorcerer', 'wizard', 'warlock']: # Caster
5055
weapon = two_handed.get('Staff', npc)
5156
if weapon:
5257
npc.insert(load_item(weapon), npc)
58+
npc.wielding = npc.locate_item(weapon['name'])[0]
5359
return
5460
if occupation in ['healer', 'cleric', 'priest', 'monk']: # Healer
5561
potion = random.choice([item for item in world_items if item and item['type'] == 'Health'])
@@ -60,12 +66,14 @@ def equip_npc(npc: LivingNpc, world_items: list[dict], setting: str = 'fantasy')
6066
weapon = _get_item_by_name_or_random('Dagger', one_handed)
6167
if weapon:
6268
npc.insert(load_item(weapon), npc)
69+
npc.wielding = npc.locate_item(weapon['name'])[0]
6370
return
6471
if occupation in ['peasant', 'farmer', 'commoner', 'villager']:
6572
if random.random() > 0.3:
6673
weapon = _get_item_by_name_or_random('Pitchfork', one_handed)
6774
if weapon:
6875
npc.insert(load_item(weapon), npc)
76+
npc.wielding = npc.locate_item(weapon['name'])[0]
6977

7078
def _get_item_by_name_or_random(name: str, items: dict) -> dict:
7179
if not items:
@@ -89,4 +97,5 @@ def dress_npc(npc: LivingNpc, setting: str = 'fantasy', max_attempts = 5) -> Non
8997
max_attempts -= 1
9098
continue
9199
npc.insert(wearable_item, npc)
100+
npc.set_wearable(wearable_item, wear_location=wearable_item.wear_location)
92101
return

tale/shop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def shop_list(self, parsed: ParseResult, actor: Living, brief: bool = False) ->
182182
if not brief:
183183
actor.tell("%s shows you a list of what is in stock at the moment:" % lang.capital(self.subjective), end=True, evoke=True)
184184
txt = ["<ul> # <dim>|</><ul> item <dim>|</><ul> price </>"]
185-
for i, item in enumerate(sorted_by_title(self.inventory), start=1):
185+
for i, item in enumerate(sorted_by_title([item for item in self.inventory if item not in self.get_worn_items()]), start=1):
186186
price = item.value * self.shop.sellprofit
187187
txt.append("%3d. %-30s %s" % (i, item.title, mud_context.driver.moneyfmt.display(price)))
188188
actor.tell( "\n".join(txt), format=False)

tale/wearable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def random_wearable_for_body_part(bodypart: WearLocation, setting: str = 'fantas
4242
# TODO: Fix name
4343
wearable = wearables[wearable_name]
4444
wearable['name'] = wearable_name
45-
wearable['short_descr'] = f"A {wearable['name']} in {random.choice(wearable_colors)}"
45+
wearable['short_descr'] = f"{random.choice(wearable_colors)} {wearable['name']}"
4646
return wearable
4747

4848
wearable_colors = ['black', 'green', 'blue', 'red', 'yellow', 'white', 'brown', 'grey', 'purple', 'orange', 'pink', 'cyan', 'magenta']

tests/test_equip_npc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def test_equip_soldier(self):
2424

2525
assert npc.inventory
2626
assert npc.money > 0
27+
assert npc.wielding.name in ['sword', 'spear']
2728

2829
def test_equip_wolf(self):
2930

@@ -36,6 +37,7 @@ def test_equip_wolf(self):
3637

3738
assert not npc.inventory
3839
assert npc.money == 0
40+
assert npc.wielding.name not in ['sword', 'spear']
3941

4042
def test_equip_centaur(self):
4143
driver = IFDriver(screen_delay=99, gui=False, web=True, wizard_override=True)
@@ -49,12 +51,15 @@ def test_equip_centaur(self):
4951

5052
assert npc.inventory
5153
assert npc.money > 0
54+
assert npc.wielding
55+
assert npc.wielding.name in ['sword', 'spear']
5256

5357
def test_dress_npc_with_wearables(self):
5458
npc = LivingNpc('Test', gender='m')
5559
setting = 'fantasy'
5660
dress_npc(npc, setting, max_attempts=50)
5761
assert npc.inventory
62+
assert npc.get_worn_items()
5863

5964
def test_get_by_name_or_random(self):
6065
items = [{"name": "Sword", "type": "weapon", "value": 100, "weapon_type":"ONE_HANDED"}, {"name": "Spear", "type": "weapon", "value": 100, "weapon_type":"TWO_HANDED"}, {"name": "shield", "type": "armor", "value": 60}, {"name": "boots", "type": "armor", "value": 50}]

0 commit comments

Comments
 (0)