Write Your Game Lore Like an Encyclopedia, Not a Novel

Leader ●3 ●10 ●152
calendar_today ago • schedule2 min read

Plenty of us here have tried giving a game character an LLM brain, and the first version usually starts inventing its own world within ten minutes. This post is about a fix that is mostly a writing problem rather than a code problem: how you structure lore so the model gets the right facts at the right moment.

How Retrieval Picks What the Model Sees

Pasting your whole world into a system prompt stops working once the world gets big. The usual answer is retrieval. Lore is split into chunks, each chunk gets an embedding, and on every player message the server finds the chunks closest in meaning and passes only those to the model alongside the conversation.

The catch is that retrieval can only return what your chunks contain, and a chunk's embedding is an average of everything in it. A chunk about one tavern has a sharp fingerprint. A chunk that covers the tavern, the war, three characters and a currency system has a blurry one, and it either matches everything a little or nothing well.

One Topic per Chunk

So write lore the way an encyclopedia is written. One entry for each place, one for each character, one for each rule of the world, each short enough to stand on its own. Name the subject in the entry itself, not just in a heading, so the chunk still makes sense when it is pulled out alone.

Novel style writing works against you here. A beautiful chapter that introduces five characters through a conversation is hard for retrieval to use, because the facts about any one character are scattered across it. Keep the prose for the narrator to produce, and keep the source material plain.

Tags help too. Put the world bible in one collection, item and rules references in another, and point each bot only at what it needs. When a character fails to know something, search the tag directly with the same prompt and you will usually see the problem in seconds: the fact was never chunked on its own.

Keep Temporary State Out of the Lore

Lore should hold what is always true. What is true for this player, or true only tonight, belongs somewhere else. Per player memories handle the first, and a per request rule string like "the player is wounded and cannot fight" handles the second without rewriting the world.

Mixing them is how lore rots. Once the knowledge base contains "the bridge is burned" from one player's session, every other player inherits it.

Wrapping Up

If you want to try this without building the plumbing, AbraTabia AI Storyteller is a free open source server, one PHP app and one SQLite file, that handles chunking, retrieval, per player memory and turn based play for up to 10 players behind one chat endpoint. Write the lore as entries, let retrieval do the selecting, and your narrator will stay inside your world.

🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

Your AI Doesn't Just Write Tests. It Runs Them Too.

Kevin Martinez - May 12

Sovereign Intelligence: The Complete 25,000 Word Blueprint (Download)

Pocket Portfolio - Apr 1

AI Reliability Gap: Why Large Language Models are not for Safety-Critical Systems

praneeth - Mar 31

Architecting a Local-First Hybrid RAG for Finance

Pocket Portfolio - Feb 25

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19
chevron_left
4.6k Points • 165 Badges
United States • t.co/5LlztlB5C5
112Posts
19Comments
26Connections
Our AI Apps are a self expanding AI SaaS ecosystem used to create the custom web application of your... Show more

Related Jobs

View all jobs →

Commenters (This Week)

33 comments
2 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!