Loot Table
A loot table picks what drops from a list of items, each with a weight. A bigger weight means the item drops more often. Each item's chance is exactly its weight divided by all the weights added up. Use whole numbers for the weights, and make sure the random roll is fair.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Loot Table" to my game.
What it should do: Random rewards with chances you control, so most drops are common, some are rare, and the odds are exact and easy to change.
Use these starting values:
- seed: 1
- rollsPerOpening: 1
Watch out for these common mistakes:
- Weights with decimals: Tell your AI: use whole numbers for weights. For a table in percent, use weights that add up to 100, or to 10,000 for finer chances.
- Low rolls come up too often: Tell your AI: draw again when the random number falls past the last whole multiple of the total.
- A table with nothing in it: Tell your AI: if the total is zero, drop nothing, and check every table when it loads.
- Changing one weight changes every chance: Ask your AI to show you the final chances, not only the weights, and add an item for nothing whose weight can soak up a change.
Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
What it does
Random rewards with chances you control, so most drops are common, some are rare, and the odds are exact and easy to change.
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| seed | 1 | The starting number for the randomness. The same seed always gives the same drops. |
| rollsPerOpening | 1 | How many rolls one opening makes, so a chest can give several items. |
What usually goes wrong
Weights with decimals
Weights such as 0.1 do not add up exactly. A roll can run past the last item and give nothing, and the real chances differ from the ones you wrote.
Fix: Tell your AI: use whole numbers for weights. For a table in percent, use weights that add up to 100, or to 10,000 for finer chances.
Low rolls come up too often
The usual shortcut for cutting a 32-bit random number down to size favours low rolls, a little for small tables and a lot for very large totals.
Fix: Tell your AI: draw again when the random number falls past the last whole multiple of the total.
A table with nothing in it
An empty table, or one where every weight is zero, has nothing to roll for, and dividing by the total fails.
Fix: Tell your AI: if the total is zero, drop nothing, and check every table when it loads.
Changing one weight changes every chance
Raising one item lowers all the others, because each chance is a share of the total.
Fix: Ask your AI to show you the final chances, not only the weights, and add an item for nothing whose weight can soak up a change.
How to check it works
- Ask your AI for a table with weights 2, 3 and 1. it goes through the rolls 0 to 5: they land on items 0, 0, 1, 1, 1, 2.
- Ask your AI for a table with an item of weight 2 between two items of weight 0. it goes through every roll: all of them land on that item.
- Two chests with the same seed. you open both: the drops are the same, and another seed gives other drops.
- An empty table, or one where every weight is zero. you open it: nothing drops and nothing breaks.
Works well with
- Inventory System: A full inventory must never make a drop vanish without a word. Roll first, then add the drop to the inventory. If it does not fit, the game must say so.
Common questions
how do you make a loot table
Give each item a whole-number weight and add the weights up. Roll a whole number below the total, then go down the list, subtracting each weight until the roll falls inside an item.
how do weighted random drops work
Each item's chance is its weight divided by the total of all weights. An item of weight 5 in a table with a total of 100 drops one time in twenty.
what do i tell my ai to add a loot table
Paste this: Add a loot table. Give every item a whole-number weight, never a decimal, so the chances add up exactly and every roll lands, and make sure the random roll is fair.
how do i add a chance of no drop
Add an item for nothing, with its own weight. It works like any other item, and it gives you one number to raise or lower how often anything drops at all.
Where it comes from
Earliest example we could find: Dave Arneson's Loch Gloomin stocking tables (Blackmoor home campaign) (1972). Arneson stocked a new adventure area from his own tables, rolling dice for gold and using random tables for items. This is known second-hand: the notes were reprinted in First Fantasy Campaign (Judges Guild, 1977), and the date comes from the researcher DHBoggs reading that reprint. The reprint itself was not seen for this entry.
- 1972 Dave Arneson's Loch Gloomin stocking tables (Blackmoor home campaign): Arneson stocked a new adventure area from his own tables, rolling dice for gold and using random tables for items. This is known second-hand: the notes were reprinted in First Fantasy Campaign (Judges Guild, 1977), and the date comes from the researcher DHBoggs reading that reprint. The reprint itself was not seen for this entry. [The Magic of Treasure! (DHBoggs, Hidden in Shadows blog, 2015)][Character Growth and Dungeon Stocking (DHBoggs, Hidden in Shadows blog, 2020)][Reactions to OD&D: The Arnesonian Dungeon (The Alexandrian, 2018)]
- 1974 Dungeons & Dragons, Volume 2: Monsters & Treasure (Gygax and Arneson, Tactical Studies Rules): Earliest printed rules seen directly for this entry. A table gives each monster a treasure type, and each type lists dice ranges and chances for coins, gems, jewelry and magic. Follow-up tables turn a magic result into a specific item, so a hoard is built by successive rolls. As printed, the treasure applies to encounters in a monster's lair. The rulebook was read in an unofficial copy, which is not linked here. [Dungeons & Dragons (1974), Wikipedia, bibliographic reference][Loot Drop Tables (Daniel Cook, Lostgarden, 2014)]
- 1980 Rogue (Michael Toy, Glenn Wichman, later Ken Arnold): Computer dungeon game that generated its level layout and placed objects at random on each run, so treasure could not be memorized. The designer's own history confirms the generated dungeon but not the item rules; the statement about objects rests on Wikipedia, and the year is the approximate one given there. [Rogue (video game), Wikipedia][A Brief History of Rogue (Glenn R. Wichman, 1997)]
- 1996 Diablo (Blizzard North, formerly Condor): Moved random treasure from turn-based dungeon games into a real-time action RPG in which monsters drop items. The 1994 pitch already planned for treasures to be placed at random. Brevik later said the game was built around loot from the start and compared killing monsters to pulling a slot machine lever. [Diablo game concept (Condor, Inc., 1994), hosted by David Brevik][Here's a look at the original design pitch document for Diablo (Alex Wawro, Game Developer, 2016)][Diablo (Jimmy Maher, The Digital Antiquarian, 2023)][Why Video Game Loot Is So Addictive, According To The Creators Of Diablo (Nathan Grayson, Kotaku, 2021)][Diablo (video game), Wikipedia]
- 2009 Borderlands (Gearbox Software): A shooter whose guns are assembled from randomly combined parts, rather than chosen from a fixed list of hand-made items. The developers describe the starting question as how to make a lot of guns. Generated weapons and items reach the player from enemies, chests, vendors and quests. [Interview: Gearbox Software explains their love of guns and Borderlands 2 (Ryan Kuo, Kill Screen, 2012)][Borderlands (video game), Wikipedia]
- 2014 Loot Drop Tables, essay by Daniel Cook: Design essay that describes the structure in general terms: items go into a bucket with weights, and a roll selects from the bucket. It also links the method back to tabletop D&D. It is a late written explanation of the technique and does not date the origin of the term. [Loot Drop Tables (Daniel Cook, Lostgarden, 2014)]
What was checked
- 14 tests pass on the reference code.
Your AI gets the code
Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it