I'm prototyping a game in where the user taps a button and a item randomly appears.
Object A = 10% chance of discovery
Object B = 15% chance of discovery
Object C = 12% chance of discovery etc... totalling 100%
Over the progression of the game, the user may increase the odds of finding certain objects, for example increasing Object A's probability from 10% to 15%.
I'm wondering if anyone can suggest an efficient design or function for running through probabilities and returning an object.
At first I considered just randomly generating a number from 1 to 100, and then using a series of if/else if statements, but this seems tedious and not very malleable for updating item probabilities. Also, should I store the probabilities in and NSDictionary?
Any suggestions appreciated. I'm writing in Objective-C. Thanks