Dungeons and Dragons (D&D) is a popular tabletop role-playing game that allows players to create their own characters and embark on epic adventures in a fantasy world. One of the key elements of a great D&D campaign is the non-player characters (NPCs) that players encounter along the way. These NPCs can help provide clues, offer quests, or even become allies or enemies to the players. In this blog, we will explore how prompt engineering techniques like instruction prompting, self-consistency sampling, and chain of thought prompting can be used to create engaging and believable NPCs.
Instruction Prompting for NPC Creation
Instruction prompting is a technique used in natural language processing tasks to guide users in generating high-quality responses. It involves designing effective prompts that provide specific instructions and suggestions to users.
Example of instruction prompting for Non-player character creation: To create a single D&D NPC, please input the following information:
The input may look something like this. Create for me a single Dungeon and Dragon NPC. For each include their, class, race, sex, appearance, unique, positive quirk, negative quirk, a personality tic, their speech patterns and voice sound, a common saying, their most prized possession, gender identity, and current motivation.
Class: [e.g. Fighter, Rogue, Wizard, etc.] Race: [e.g. Human, Elf, Dwarf, etc.] Sex: [e.g. Male, Female, Non-binary] Appearance: [e.g. Tall, Short, Scrawny, Muscular, etc.] Unique feature: [e.g. Scar, Tattoo, Missing Limb, etc.] Positive quirk: [e.g. Polite, Generous, Brave, etc.] Negative quirk: [e.g. Greedy, Arrogant, Cowardly, etc.] Personality tic: [e.g. OCD tendencies, Superstitious, Always Doubts Themselves, etc.] Speech patterns and voice sound: [e.g. Gruff, High-pitched, Monotone, etc.] Common saying: [e.g. "Time is money," "Fortune favors the bold," "Trust no one," etc.] Most prized possession: [e.g. Family Heirloom, Magic Weapon, Stolen Treasure, etc.]
Gender identity: [e.g. Cisgender, Transgender, Genderqueer, etc.] Current motivation: [e.g. Seeking Revenge, Protecting Loved Ones, Accumulating Wealth, etc.] -----------------------------------------------Output------------------------------------------------------- Class: Bard Race: Half-Elf Sex: Male Appearance: Lean and muscular, with long curly black hair and piercing green eyes. Unique feature: A gold earring in his left ear. Positive quirk: Always ready to lend a helping hand to those in need. Negative quirk: Has a tendency to drink too much and become rowdy. Personality tic: Prone to bouts of melancholy and existential pondering. Speech patterns and voice sound: Smooth and melodious, with a hint of a foreign accent. Common saying: "Life is but a song, and I am its humble troubadour." Most prized possession: His prized lute, which he inherited from his elven mother. Gender identity: Cisgender Current motivation: Seeking inspiration for his next great ballad, and hoping to win the heart of a beautiful noblewoman.
Self-Consistency Sampling for NPC Creation
Self-Consistency Sampling is a technique used in natural language processing to generate high-quality text based on a given prompt.
To use Self-Consistency Sampling for character creation in D&D, one can start with a prompt that describes the character's basic traits such as race, gender, class, and appearance. Then, the technique can be used to generate additional details that are consistent with the initial prompt.
For example:
Prompt: Half-Elf Bard, male, tall and lean, with long curly black hair and piercing green eyes.
Step 1: Generate a positive quirk that is consistent with the prompt.
Output: Always carries a small leather-bound book of poetry with him.
Step 2: Generate a negative quirk that is consistent with the prompt. Output: Tends to be too trusting of others, even when they don't deserve it.
Step 3: Generate a personality tic that is consistent with the prompt.
Output: Has a tendency to sing to himself when he's feeling anxious or nervous.
Step 4: Generate a unique feature that is consistent with the prompt.
Output: Has a small, intricate tattoo of a lyre on his left wrist.
Step 5: Generate a common saying that is consistent with the prompt.
Output: "Music is the language of the soul."
Step 6: Generate the NPC's most prized possession that is consistent with the prompt. Output: A beautiful, hand-crafted lute that he inherited from his elven mother.
Step 7: Generate the NPC's current motivation that is consistent with the prompt. Output: He's searching for a lost love who disappeared while he was away on a long journey.
By using Self-Consistency Sampling, we were able to generate additional details about the character that are consistent with the initial prompt. This can help create a more fleshed-out and believable character that is easier to role-play.
Chain-of-Thought Prompting for NPC Creation
Chain-of-Thought Prompting is a technique used in natural language processing to generate coherent and fluent text by encouraging users to continue their thought processes in a specific direction
To use Chain-of-Thought Prompting for NPC creation in D&D, we can start with a basic prompt and use related questions to prompt the user to continue their thought process in a specific direction.
For example:
Prompt: Dwarf Cleric, male.
CoT Prompt 1: What motivated this character to become a cleric?
Output: He saw the impact that religion had on his community and wanted to use his faith to help others.
CoT Prompt 2: What is his relationship with his deity like?
Output: He sees his deity as a mentor and guide, someone to turn to for advice and guidance.
CoT Prompt 3: What are his thoughts on other races and religions?
Output: He believes that all sentient beings are capable of good or evil, and it's up to individuals to choose their path.
CoT Prompt 4: How does he feel about violence?
Output: He sees violence as a last resort, and would much rather resolve conflicts peacefully.
CoT Prompt 5: Does he have any notable flaws or weaknesses?
Output: He can be overly trusting, and has been taken advantage of in the past because of this.
By using Chain-of-Thought Prompting, we were able to create a chain of related thoughts and generate additional details about the character's motivations, relationships, beliefs, and flaws. This can help create a more complex and interesting NPC that players will enjoy interacting with.
Prompt engineering techniques like instruction prompting, self-consistency sampling, and chain-of-thought prompting can be incredibly useful for creating engaging and believable NPCs in D&D. By providing a set of specific prompts and using these techniques to generate additional details, we can create NPCs that feel like real characters with their own motivations, quirks, and flaws. This can help make D&D campaigns more immersive and enjoyable for everyone involved.
Citation
Weng, Lilian. (Mar 2023). Prompt Engineering. Lil’Log. https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/.
Comments