I am making a dungeon crawler; as the player character adventures down through increasingly difficult floors of a dungeon, they collect more valuable treasure.

What is a good algorithm to determine the distribution of treasure? Should each potential item be given a range from one to a million and then be rolled for, or should multiple dice with special value be rolled and an item constituted that way?

For this example there can be an infinitely varied assortment of randomly generated items.

  • 3
    \$\begingroup\$ That all depends on your design. Each way has it's pros/cons. \$\endgroup\$
    – Kromster
    Oct 14, 2014 at 13:01
  • 1
    \$\begingroup\$ Make sure your total outcomes reaches 100%. Then break that 100% down by different loot rarities. 40% normal 30 % magic 20 % 10% rare 5% set item and 5% unique. You can use this to determine how many affixes your item will carry, and how good they will be, or whatever you decide to do. \$\endgroup\$
    – Shroeder
    Oct 14, 2014 at 13:18

4 Answers 4


These are the three approaches that I would take:

Loot tables:

Build a table for each zone and sub-area. Loot table should be approximately close to the theme and difficulty level of the enemies, I.e. if it is intro level and mobs can range from level 1-3, then so should the loot. You can make different loot drop tables for specific sub-areas as well. If you have a dungeon and a small area specifically where the orks hang out, then your loot table for that sub area may have items specific to orks, i.e. "ork swords, or ork shields"

If you are editing a level or automatically generating it then the loot tables should be generated the same way your terrain/mobs are. Your loot should be proportional to the difficulty of the dungeon level (or the mobs for that level).

For game balance you should take into account risk/reward. Boss gear should be given when fighting tougher enemies. Otherwise you risk getting the best gear from simple mobs and removing the fun element from your dungeon.

Here would be an example of a loot table

Zone 1 loot table:

  • Item,Difficulty,Chance
  • Regular Orc Shield, 1-3, 20%
  • Regular Orc Sword, 1-3, 20%
  • Some gold (5-10gp), 1-3, 80%
  • {Awesome sword -or- Awesome Shield}, 5, 20%

Manually generated games use these, so for example if you want to scavenge a particular area for ingridients or craftings parts, the loot table for that area would contain particular parts (i.e finding food in jungle areas, finding electronics in junk yard) etc.

Standard Deviation:

Some games use standard deviation for loot drops. For example the more common the item, the close it is to the average. The more exotic items the further it is from the average and closer to the sides of the curve. This can be used with loot tables, or it can be used for the overall game. If you are making a space shooter and the only things that can be dropped are power ups and parts, then you don't need a loot table, you can just use the standard deviation and define the probability threshold for the items.


  • Health (Common), .5
  • Ammo (Common), .5
  • Cool gun (Uncommon), .7
  • Super gun (Rare), .9

The common items, statistically, should drop more often then the rare ones.

Pure Random

I would actually use this method when starting to make the game because it is the easiest to implement. You do not want to optimize your game when you are still making it, you can always worry about balance and mechanics a bit later in your development cycle. Also having random drops may seem amusing and might also give you ideas during play testing. For example having super loot drop when you are in the tutorial may give you some ideas to create some quest named "Holy Quest to get Super Loot". I.e. it is good for brainstorming.


I would suggest that in addition to using random numbers, it would be more interesting and logical, and good for play balance and sense of immersion, if the loot were related to the nature of the place and what else is there. Not just how deep into the dungeon it is, but what is the nature of each part of each dungeon level.

Whether pre-designed or randomly generated, each room or passage or section of a dungeon level can have a type, which can influence how it is laid out, what is there, what it looks like, and what creatures and objects (loot) will tend to be there.

As I particularly like things to make sense, I would think about what loot would make sense to go in what area and with what opponents, and if the loot is useful gear that the opponents can use, equip them with it so they can use it against the players. It always seems pretty fake to me when there is, say, a warrior standing around next to some great weapons, or a wizard hanging around some magic equipment, which are just prizes for the player and not being used by the opponents who were there first.

So, your algorithm could be like:

  1. Determine what each section of each level is like, based on a semi-random selection of odds for each type of section to appear on each level depth, and also based on what sections are adjacent to it, so the layout will make more sense than being completely random.

  2. For each section, now that we know the type, generate features and place pseudo-random monsters appropriate to that type of place.

  3. For each monster, add pseudo-random gear that that monster can use but could also be looted, and a much smaller chance of them just having random stuff they can't use themselves. Also check the monsters against the other monster types to see if they make sense to be hanging out together, or if one would have fled or been killed by another.

  4. Add other logical loot for the place type, in logical places. Maybe check against each monster in that region to see whether it is something they would have pocketed before the player shows up, or not.


or should multiple dice with special value be rolled and then an item constituted that way

Why would this be better? The player would not see the "dice", the first example is as much a "dice" as the second.

I think you need to make all the items you want and consider their relative usefulness before starting to think about their distribution.

Also, I think it's really boring when you beat a rat and for some reason it drops something incongruous like a sword. It's a rat, why would it be carrying around a sword? Where did it keep it? I like it way better when monsters/chests drop things you'd expect them to drop. It sounds to me like you want a Diablo like loot system. In that case you'd do well to read up on these FAQs describing the drop mechanics.

  • \$\begingroup\$ Thanks that example is great, for anyone reading the specific FAQ is gamefaqs.com/mac/563384-diablo-ii-lord-of-destruction/faqs/… \$\endgroup\$ Oct 14, 2014 at 14:02
  • \$\begingroup\$ This answer could be improved by explaining what exactly it is you could learn from Diablo's loot system. Also, there are great ideas for how to implement "sensible" drops from creatures in this article. \$\endgroup\$
    – Anko
    Oct 14, 2014 at 20:01

This is how I ended up doing it (based on Diablo II):

Loot Tables

Each enemy that is killed has a certain enemy class. For example, a regular melee lvl 20 character's code might be MA-20, and an elite melee of the same level would be MC-20.

Every code is paired to a "loot" table containing any number of fields. Each field has a reward and a probability.

Loot Table for MA-20

item - probability
gold - 20
nothing - 80
weapons.simpleDagger - 5
MC-20 - 1

To determine the loot dropped, each possible reward is assigned a range based on its probability, and then a random number is rolled. In this case, the random number is 106.

gold - 20 - awarded on 0-20
nothing - 80 - awarded on 21-100
weapons.simpleDagger - 5 - awarded on 101-105
MC-20 - 1 - awarded on 106

Each slot can either be gold, nothing, an item, or point to another table. If the roll lands on an item, the enemy drops that item. If it lands on another table, then that table is then rolled for, continuing indefinitely until an item is drawn.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .