Design model of the item drop probability table ~ Drop probability table id & nbsp; item id & nbsp; Adventure & nbsp; activity & nbsp; & nbsp; Copy & nbsp; design mode of Battle & item drop probability table
The younger brother posted the post for the first time ~
Drop probability table
Id item id adventure activity copy battle...
1 5 8 10 12 14
2 7 15 5 20 0
3 9 20 0 30 0
The probability that an item (item id) drops in an action (such as adventure or copy)
Can I create this table like this?
How to write PHP code?
For example, the probability that the item id5 is obtained when the copy is obtained
$ A = mt_rand (); // 8 + 10 + 12 + 14 = 44
If ($
?) {// Random number greater than 18 and less than 30
// Here is the code for getting the item
}
Don't know? How to write, that is, how to get at 18 and 30
Share with PHP mysql:
------ Solution --------------------
I don't know why.
However, if I did it, I would definitely directly rand (0,100) and then verify if it is smaller than 12. 12 is 12%.
What does your code mean by adding up the probability of 100% in several ways? I don't understand why this setting exists.
------ Solution --------------------
Listen to the first floor, as long as the judgment is less than 12 is your copy probability
------ Solution --------------------
Is there another hidden condition for the landlord not to mention? : Can I drop at most one device at a time?
------ Solution --------------------
The sum of probabilities is 1 (100%). you need to clarify your requirements and then ask again.