Skip to content

Commit ccc06e7

Browse files
authored
Merge pull request #42 from neph1/random_spawns
Random spawns
2 parents a1535f2 + 16fcdba commit ccc06e7

File tree

19 files changed

+404
-123
lines changed

19 files changed

+404
-123
lines changed

llm_config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@ COMBAT_PROMPT: 'Rewrite the following combat between user {attacker} using {atta
1818
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.\n\n'
1919
CREATE_CHARACTER_PROMPT: '### Instruction: For a {story_type}, create a diverse character with rich personality that can be interacted with using the story context and keywords. Do not mention height. Story context: {story_context}; keywords: {keywords}. Fill in this JSON template and write nothing else: {{"name":"", "description": "50 words", "appearance": "25 words", "personality": "50 words", "money":(int), "level":"", "gender":"m/f/n", "age":(int), "race":""}}\n\n ### Response:\n'
2020
CREATE_LOCATION_PROMPT: '[Story context: {story_context}]; World info: {world_info}; Zone info: {zone_info}; Exit json example: {{"direction":"", "name":"name of new location", "short_descr":"exit description"}}; Npc or mob example: {{"name":"", "sentiment":"", "race":"", "gender":"m, f, or n", "level":(int), "description":"25 words"}}. Existing connected locations: {exit_locations}. ### Instruction: For a {story_type}, 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: {{"description": "25 words", "exits":[], "items":[], "npcs":[]}}. Write the response in valid JSON.\n\n ### Response:\n'
21-
CREATE_ZONE_PROMPT: '[Story context: {story_context}]; World info: {world_info}; ### Instruction: For a {story_type}, create an new area that can be further populated with locations. The area is about 25 square kilometers. It is connected in the {direction} to {zone_info}. The mood is {mood}. 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: {{"name":"", "description": "75 words", "races":[], "items":[], "mood":"friendly, neutral, hostile, very hostile or nightmare", "level":(int)}}. Write the response in valid JSON.\n\n ### Response:\n'
21+
CREATE_ZONE_PROMPT: '[Story context: {story_context}]; World info: {world_info}; ### Instruction: For a {story_type}, create an new area that can be further populated with locations. The area is about 25 square kilometers. It is connected in the {direction} to {zone_info}. The mood is {mood}. 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: {{"name":"", "description": "75 words", "races":[], "items":[], "mood":"5 to -5, where 5 is extremely friendly and -5 is extremely hostile.", "level":(int)}}. Write the response in valid JSON.\n\n ### Response:\n'
2222
OPENAI_HEADERS: '{"Content-Type":"application/json", "Authorization":""}'
2323
OPENAI_BODY: '{"model":"gpt-3.5-turbo", "messages":[{"role":"system", "content":"You are an assistant game keeper for an RPG"}, {"role":"user", "content":""}], "temperature": 1.0, "max_tokens":500}'
2424
OPENAI_API_KEY: "OPENAI_API_KEY"
2525
ITEMS_PROMPT: "Add {items} of various type."
26-
SPAWN_PROMPT: "Add a level {level}, {alignment} npc."
26+
SPAWN_PROMPT: "Add a level {level}, {alignment} npc or mob."
2727
IDLE_ACTION_PROMPT: " [Sentiments towards characters: {sentiments}] [Last action: {last_action}] [Location: {location}] [Acting character: {character}] ### Instruction: Choose an item from: {items}, or a character from:{characters}, to interact with, or perform a solo action. Do not make up new characters. Don't contradict or repeat Last Action. ### Instruction: Write what {character_name} does, in present tense third person point of view. Use less than 40 words. Don't write what {character_name} thinks, or what the player (You) or anyone else does.\n\n ### Response:\n"
2828
TRAVEL_PROMPT: "### Instruction: For {character}: pick a location from [{locations}] they would like to travel to or a direction from [{directions}], or stay in the current location. Do not make up new locations. Write what {character_name} chooses. ### Instruction: Write only the location name, direction, or write nothing to stay in the same location. Write nothing else.\n\n ### Response:\n"
2929
REACTION_PROMPT: "### Instruction: Act as {character}. {acting_character_name} has performed the following action that involves {character_name}: {action}. {character_name}'s sentiment towards {acting_character_name}: {sentiment}. ### Instruction: Respond with a suitable action for {character_name}, in present tense third person point of view. Use less than 40 words.\n\n ### Response:\n"
3030
STORY_BACKGROUND_PROMPT: "### Instruction: For an RPG described as {story_type} set in a world described as {world_mood}, {world_info}, write a captivating background story that the player can interact with. Include a large scale plot conflict that the player will encounter. Use less than 400 words\n\n ### Response:\n"
3131
START_LOCATION_PROMPT: '[Story context: {story_context}]; Zone info: {zone_info}; Item json example: {{"name":"", "type":"", "short_descr":"10 words"}}, type can be "Weapon", "Wearable", "Other" or "Money"; Npc example: {{"name":"", "sentiment":"", "race":"", "gender":"m, f, or n", "level":(int), "description":"25 words"}} ; Exit json example: {{"direction":"", "name":"name of new location", "short_descr":"exit description"}}; ### Instruction: For a {story_type}, come up with a name for the location with this description: {location_description}. {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: {{"name": "", "exits":[], "items":[], "npcs":[]}}.\n\n ### Response:\n'
3232
STORY_PLOT_PROMPT: "### Instruction: For an RPG described as {story_type} set in a world described as {world_mood}, {world_info}. Based on the following background: {story_background} write an innovative and engaging plot that the player can become part of. Use less than 400 words\n\n ### Response:\n"
33-
WORLD_ITEMS: '[Story context: {story_context}]; For an RPG described as {story_type} set in a world described as {world_mood}, {world_info}, come up with 7 common items that can be found in the world. Item example: {{"name":"", "type":"", "short_descr":"", "level":int, "value":int}}, type can be "Weapon", "Wearable", "Health", "Other" or "Money"; Fill in this JSON template and do not write anything else: {{"items": []}}.\n\n ### Response:\n'
33+
WORLD_ITEMS: '[Story context: {story_context}]; For an RPG described as {story_type} set in a world described as {world_mood}, {world_info}, come up with 7 common items that can be found in the world. Item example: {{"name":"", "type":"", "short_descr":"", "level":int, "value":int}}, type is one of: {item_types}; Fill in this JSON template and do not write anything else: {{"items": []}}.\n\n ### Response:\n'
3434
WORLD_CREATURES: '[Story context: {story_context}]; For an RPG described as {story_type} set in a world described as {world_mood}, {world_info}, come up with 5 creatures of various level and sentiment that can be found in the world. Creature example: {{"name":"", "body":"", "mass":int(kg), "hp":int, "type":"Npc or Mob", "level":int, "unarmed_attack":One of [FISTS, CLAWS, BITE, TAIL, HOOVES, HORN, TUSKS, BEAK, TALON], "short_descr":""}}. Fill in this JSON template and do not write anything else: {{"creatures": []}}.\n\n ### Response:\n'
3535
GOAL_PROMPT: '[Characters:{characters}][Sentiments towards characters: {sentiments}] [Last action: {last_action}] [Location: {location}] [Known locations: {locations}][Acting character: {character}] [Actions available:{actions}] ### Instruction: For {character_name}, come up with a goal that plays along with their character description that involves an item, a character or a location in the prompt. Then construct up to three tasks that will lead towards the achievement of said goal. Fill in the following JSON template: {{"goal":"", "tasks":[{"action":"", "what":""}, {"action":"", "what":""}, {"action":"", "what":""}]}}\n\n ### Response:\n'
36-
JSON_GRAMMAR: "root ::= object\nvalue ::= object | array | string | number | (\"true\" | \"false\" | \"null\") ws\n\nobject ::=\n \"{\" ws (\n string \":\" ws value\n (\",\" ws string \":\" ws value)*\n )? \"}\" ws\n\narray ::=\n \"[\" ws (\n value\n (\",\" ws value)*\n )? \"]\" ws\n\nstring ::=\n \"\\\"\" (\n [^\"\\\\] |\n \"\\\\\" ([\"\\\\/bfnrt] | \"u\" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes\n )* \"\\\"\" ws\n\nnumber ::= (\"-\"? ([0-9] | [1-9] [0-9]*)) (\".\" [0-9]+)? ([eE] [-+]? [0-9]+)? ws\n\n# Optional space: by convention, applied in this grammar after literal chars when allowed\nws ::= ([ \\t\\n] ws)?"
36+
JSON_GRAMMAR: "root ::= object\nvalue ::= object | array | string | number | (\"true\" | \"false\" | \"null\") ws\n\nobject ::=\n \"{\" ws (\n string \":\" ws value\n (\",\" ws string \":\" ws value)*\n )? \"}\" ws\n\narray ::=\n \"[\" ws (\n value\n (\",\" ws value)*\n )? \"]\" ws\n\nstring ::=\n \"\\\"\" (\n [^\"\\\\] |\n \"\\\\\" ([\"\\\\/bfnrt] | \"u\" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes\n )* \"\\\"\" ws\n\nnumber ::= (\"-\"? ([0-9] | [1-9] [0-9]*)) (\".\" [0-9]+)? ([eE] [-+]? [0-9]+)? ws\n\n# Optional space: by convention, applied in this grammar after literal chars when allowed\nws ::= ([ \\t\\n] ws)?"
37+
PLAYER_ENTER_PROMPT: '[Story context: {story_context}]; World info: {world_info}; Zone info: {zone_info}; ; Npc example: {{"name":"", "sentiment":"", "race":"", "gender":"m, f, or n", "level":(int), "description":"25 words", "memories":"25 words"}}. ### Instruction: The player has just re-entered this location: {location_info}. Consider whether any items, npcs or mobs should be spawned. For mobs, only enter the name of race. Fill in this JSON template and do not write anything else: {{"items":[], "npcs":[] "mobs":[]}}.\n\n ### Response:\n'

stories/prancingllama/npcs/npcs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def do_buy_drink(self, actor: Living, drink: Item, price: float) -> None:
4242
self.money += price
4343
drink.move(actor, self)
4444
price_str = mud_context.driver.moneyfmt.display(price)
45-
actor.tell("After handing %s the %s, %s gives you the %s." % (self.objective, price_str, self.subjective, drink.title), evoke=True, max_length=True)
46-
self.tell_others("{Actor} says: \"Here's your drink, enjoy it!\"", evoke=True, max_length=True)
45+
actor.tell("After handing %s the %s, %s gives you the %s." % (self.objective, price_str, self.subjective, drink.title), evoke=True, short_len=True)
46+
self.tell_others("{Actor} says: \"Here's your drink, enjoy it!\"", evoke=True, short_len=True)
4747

4848
class Maid(LivingNpc):
4949

@@ -86,14 +86,14 @@ def do_random_move(self, ctx: Context) -> None:
8686
if not self.sitting:
8787
if random.random() < 0.25:
8888
self.sitting = True
89-
self.tell_others("{Actor} sits down.", evoke=False, max_length=True)
89+
self.tell_others("{Actor} sits down.", evoke=False, short_len=True)
9090
else:
9191
direction = self.select_random_move()
9292
if direction:
9393
self.move(direction.target, self, direction_names=direction.names)
9494
elif random.random() < 0.5:
9595
self.sitting = False
96-
self.tell_others("{Actor} stands up.", evoke=False, max_length=True)
96+
self.tell_others("{Actor} stands up.", evoke=False, short_len=True)
9797

9898
class Shanda(Patron):
9999

@@ -116,9 +116,9 @@ def init(self) -> None:
116116
@call_periodically(10, 25)
117117
def do_idle_action(self, ctx: Context) -> None:
118118
if random.random() < 0.5:
119-
self.tell_others("{Actor} hisses.", evoke=False, max_length=True)
119+
self.tell_others("{Actor} hisses.", evoke=False, short_len=True)
120120
else:
121-
self.tell_others("{Actor} sniffs around.", evoke=False, max_length=True)
121+
self.tell_others("{Actor} sniffs around.", evoke=False, short_len=True)
122122

123123

124124
norhardt = Patron("Norhardt", "m", age=56, descr="A grizzled old man, with parchment-like skin and sunken eyes. He\'s wearing ragged clothing and big leather boots. He\'s a formidable presence, commanding yet somber.", personality="An experienced explorer who is obsessed with finding the mythological Yeti which supposedly haunts these mountains. He won\'t stop talking about it.", short_descr="An old grizzled man sitting by the bar.")

0 commit comments

Comments
 (0)