Design mode of the item drop probability table: PHP mysql
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 (); // that is, 8 + 10 + 12 + 14 = 44if ($
?) {// 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
Reply to discussion (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.
Well, I mean, the probability of copying A is 10%.
Well, I mean, the probability of copying an item is 10% B. The probability is 15% C. 20%
When I create a copy, I want to obtain B. rand (10% 45%) with a value greater than 35% and less.
So are these 10 and 35?
Listen to the first floor, as long as the judgment is less than 12 is your copy probability
Is there another hidden condition for the landlord not to mention? : Can I drop at most one device at a time?
Oh, I wrote the error sorry.
The problem is that I want to drop several items, that is, view them in the table.
Less than 12%. this is the case. how can we write the same (or more )?
Enter> 12 & <a certain number
I don't know how to write this.
Let's read what I said on the third floor --
I made a mistake on the 0th floor. Oh, my God, I made a mistake.
The sum of probabilities is 1 (100%). you need to clarify your requirements and then ask again.