Development Blog

Where we pretend to know how to code.

Loot systems are a pain.

Published: 2017-02-11

Author: Teddi

If you search the internet, you’ll find people suggesting all sorts of ways of designing and developing loot tables; especially depending on the language. The problem is that in almost every case I found thus far while researching, every method has its’ drawbacks. This can be in the sense of inefficient algorithms, dependant on certain behaviours and requirements or just plain awkward.

Back when Life was being developed, a few different algorithms were designed and tested to see how it worked with item distribution, how it worked when you ‘failed’ to get an item and so on. One of these algorithms ended up being ported from Life to Surf. This algorithm had never really been completely field tested as such; but it’d proven reliable in the grand scheme of things over time. That said, with Surf and the various crate seasons we ended up discovering some of its flaws, one or two major, the rest not so much. With this blog post, chronologically I’ll be describing the findings and explanations in terms of crate seasons to try and simplify the general explanation.

Season 1 Crate

With the Season 1 crate the system appeared to work flawlessly. Duplicates didn’t occur too often and items spread out across their various chances seemed to work well. Every item was actually just about given its own chance in the loot table (though I’d keep this in mind). Overall, great success!

Season 2 Crate (1st Ed).

In the season 2 crate, a number of mistakes were probably made. For one, an incredible amount of high-value items were added. Not just that but the chances for some items were too high (one Aura had a 80% chance to be uncrated, oops).

Season 2 Crate (2nd Ed).

So the chances were reduced, but some items were still too damn high. Reduced again

Season 3 Crate (3rd Ed).

At this point I’d realised there was a flaw in the system. As I said before, in Season 1 every item had their own chance. In Season 2, this was actually changed for conveneince. Items were clustered mostly around the same chance (if not the same) which would then continously add them to a loot table. This meant under certain conditions you’d end up with a huge pool of ‘50% chance items’ (for example) that the system would then select from, as opposed to saying “this is your item, now have it”. This had a funny side-effect in that rarer items would actually end up being more common as a side-effect.

A few different fixes were implemented. One ended up accidentally shrinking the loot table, the fix for this then skewed the odds slightly thus fixing that issue, but then we were back to the original issue.

Season 3 Crate (4th Ed).

I rewrote the algorithm entirely as per Killermon’s algorithm suggestion. Previously it would check all items to see whether or not they were the lowest beyond a certain number. This for the most part is fine; but if the number was too small then it’d be more work. It also allowed for (debatable) better allocation of percentage chances, but the reality is they were probably somewhat skewed beyond what they should have been.

The new system essentially converts the chances into a lookup table which then selects a single item. This is far faster and easier to deal with - we can also calculate with extreme accuracy to what the chances should be. It doesn’t so much allow for 0.001% chance items anymore, but it does mean that items are fairly distributed and picked as opposed to constantly forcing items to roll off against each other.

Should be interesting to see how the loot system works over the next month or so - and the effects of it. If it’s interesting enough I’ll do a follow-up post.

Historical Posts