Author Topic: Item randomization  (Read 13303 times)

abraksil

  • Rogueliker
  • ***
  • Posts: 134
  • Karma: +0/-0
    • View Profile
    • Email
Item randomization
« on: March 30, 2016, 10:47:41 PM »
I'm reimplementing item randomization mechanic in my game for the 3ed time now. How do you guys design your algorithms and what kind of parameters do you use to balance it. How do you describe the loot quality available in different places on different levels?

sokol815

  • Rogueliker
  • ***
  • Posts: 85
  • Karma: +0/-0
  • Web Developer by Day, still Web Developer by night
    • View Profile
    • Email
Re: Item randomization
« Reply #1 on: March 31, 2016, 12:58:46 AM »
I'm reimplementing item randomization mechanic in my game for the 3ed time now. How do you guys design your algorithms and what kind of parameters do you use to balance it. How do you describe the loot quality available in different places on different levels?

This is a great question. A previous discussion on the topic occurred here(forums.roguetemple.com).

My personal favorite approach to drop-randomization is detailed in the thread above. I find it to be an extremely versatile system. You can easily add additional items, tweak drop rates, quality of drops, item ratios... etc. all in the same spot. Then I just assign a dropClass to my monsters and the system can choose what they drop. Alternatively, you could generate your monsters with their drops and have them use said items, which is a future goal of mine.

I'm not entirely sure if I want to match drops to the depth of the dungeon or the level of the monster... I think I'm leaning more towards the level of the monster, but if I were to implement the mechanic where monsters use whatever items they will drop, a dungeon-level-based drop rate might make sense. Additionally, it might make sense for a bat to drop a potion (they were carrying it?) but would they similarly be able to carry a chestplate? probably not... this is a future goal that I am working towards right now. The system I detailed in the thread above will make it rather easy to cobble together specific drop classes for enemies, which I think can help in making monsters not feel all 'samey'. other uses include the ability to specifically drop quest items on death of a specially spawned monster.

I just had another thought... if you met a weak monster on say level 2 (maybe a rat?) and were able to lure him down to level 5 and then kill him, it seems pretty arbitrary to say that because said rat died on level 5 he is attached to level 5's drop class... I guess that is just something additional to think about in the dungeon level vs monster dropClass.
« Last Edit: March 31, 2016, 02:54:21 PM by sokol815 »

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Re: Item randomization
« Reply #2 on: March 31, 2016, 05:22:10 AM »
I am using a very basic system in Professional Adventurers' League.  Things that are randomly generated (monsters, items, item types) have a minimum level, a maximum level, and a weight.  The generator iterates through the list, making a separate list of entries that fall within the level parameters.  A random number is generated, from zero to the sum of all weights on the second list.  The generator then goes through the list; if the random number is less than the weight of the current object, that object is returned.  Otherwise, its weight is subtracted from the randomly generated number.

It is helpful that only elite enemies drop loot in PAL; the vast majority of treasure comes from chests, so I don't have to worry much about unrealistic drops.  And most of the enemies are humanoid, which also helps.

AgingMinotaur

  • Rogueliker
  • ***
  • Posts: 805
  • Karma: +2/-0
  • Original Discriminating Buffalo Man
    • View Profile
    • Land of Strangers
Re: Item randomization
« Reply #3 on: March 31, 2016, 11:38:56 AM »
A very interesting problematic, indeed. One issue I think can create difficulties, is to make a system that scales well. In my old project, I bumped into the problem that drop rates for everything got effectively lower as more items were added. This could mean that the spawn rates for rare items might drop so close to zero that they're practically out of the game. On the other end of the spectrum, there'll be some essential tools (healing potions, ammo, whatever your player will need to be able to play at the intended pace). Again, if you have balanced the frequency of such items within a set of 30 items total, the balance might get skewed as the number of items goes up (ie. at 60 items, you only get half the healing potions you need). For my next project, I hope to make a system where I don't have to go back a rebalance item frequencies all the time.

Mind you, the right system depends on the scale of the game. For some dungeon crawlers, it can be quite well balanced if, say, levels 1-3 feature "hand axes", levels 3-6 "battle axes" and levels 6-9 "executioner's axes". For a more open world, I've always felt it makes sense that anything *could* show up at any time.

Re: the issue of making sure essential items show up, I think ADOM has an interesting solution: In addition to items with a danger level of 1 or more, there are items with a danger level of 0, which may show up at any time. This way, healing potions are sure to spawn even at deeper levels. For my current project, I've been considering something similar, maybe giving each item a frequency category ("essential" , "common", "rare", "unique"), and weighing the game so that "essential" items are sure to show up at a certain rate, regardless of all else.

Re: who drops what, I've been swearing by "treasure categories" and "tags". Categories are used to tell a being it should carry, for instance, 1 weapon, 1 armor, 0-1 rings and 0-1 scrolls. Tags are less hard and fast, and are just used to skew the probabilities, making rooms/creatures more likely to spawn items with similar tags as themselves. For example, a knight and an orc may both be set to own one "weapon". But if the knight is tagged "military", that might up the chances for things like maces and plate mails (which would also be tagged "military"); the orc could be tagged with "chaos" or something to increase the chance of spiked clubs, bone helmets, etc. Similarly, a simple instruction to carry one "tool" might give yield a lockpick for a thief, a hatchet for a farmer and a severed arm for an orc. This can be a quite powerful system, especially if implemented on a large-ish scale, with thematic rooms and such.

As always,
Minotauros
This matir, as laborintus, Dedalus hous, hath many halkes and hurnes ... wyndynges and wrynkelynges.

Zireael

  • Rogueliker
  • ***
  • Posts: 604
  • Karma: +0/-0
    • View Profile
Re: Item randomization
« Reply #4 on: March 31, 2016, 07:18:33 PM »
I am using rarities (aka. weights), as well as min and max level.

I think there is some code that was supposed to make "common", "ego", "rare", "greater" etc. items, but it isn't perfect and I will likely comment it out as it creates more problems than it solves.

NPCs equipment is determined by categories. Tags sound like a neat idea!

abraksil

  • Rogueliker
  • ***
  • Posts: 134
  • Karma: +0/-0
    • View Profile
    • Email
Re: Item randomization
« Reply #5 on: March 31, 2016, 11:43:20 PM »
Ok thx all for your insight. I decided to go with the fallowing solution:

Every drop slot has a category of drop. Like ALL, EQUIPMENT_ONLY, HERBS
Every Category is divided into sub-categories. For example ALL: WEAPON, TOOLS, FOOD. I chose a sub-category based on their weights and randomize how rare the item should be (from 1 to 4)
Subcategory is a virtual class co we can define different ways of randomization inside them. Food will be randomized always using same weights while weapon and equipment will be dependent on level. (but Taking into account previously determined rarity)
Most of the sub categories will have simple randomization algorithms but I'm still thinking about weapons. I'm don't exactly like minimal and maximal solution. I'm thinking about using Normal distribution and rule of 3 deltas. (I still need to think about it all thought)
« Last Edit: March 31, 2016, 11:46:00 PM by abraksil »

abraksil

  • Rogueliker
  • ***
  • Posts: 134
  • Karma: +0/-0
    • View Profile
    • Email
Re: Item randomization
« Reply #6 on: March 31, 2016, 11:48:38 PM »
By the way how many different items do you have in your games? I wounder how many Is there required to avoid the feeling of loot repetitiveness in the game

TheCreator

  • Rogueliker
  • ***
  • Posts: 370
  • Karma: +0/-0
    • View Profile
    • Fame
    • Email
Re: Item randomization
« Reply #7 on: April 01, 2016, 07:24:23 AM »
By the way how many different items do you have in your games? I wounder how many Is there required to avoid the feeling of loot repetitiveness in the game

I don't think this is just a matter of the number. You must ensure that every time the player finds a loot, it is useful to him in some way. This is usually easy in an early game - the player will be happy to find any armor, any weapon, any ring, and so on. As the player advances, he will need a better armor, a better weapon etc. It is still fairly easy to guarantee that he will eventually get better items, although it might be quite challenging to drop them at the right moment. The question is what to do if the player already has the best equipment available in the game (or - how to prevent this kind of situation). Anyway, creating a bunch of similar items that differ only by some numerical parameters is probably the worst solution. All items should have some interesting uses, some interactions with the world. Most of the times these interactions should be obvious (for example, healing potions can be used to heal the player, but may be also thrown on monsters to recover their HP, which in turn may have interesting consequences - some monsters might temporarily get confused, other might stop attacking the player character and go somewhere else). Some interactions (but not too many) may be totally crazy and unexpected (like throwing out potions of uselessness in ADOM). The more ideas you put in the game, the better, because it's ideas what really counts, not bare numbers.
Fame (Untitled) - my game. Everything is a roguelike.