mardi 22 janvier 2019

How to put probability into random generation of multiple items?

I am working on a browser based game using PHP to make it useable by individuals who use screen reading software. I want to use a button click by the player to use a skill, for example Search, and the system randomly select items that are found; some items are more rare than others so should show up less frequently. How would I implement probability into the random selection of these items and allow the player to select the ones they want?

I have looked around and found many examples of using one or more arrays with the Rand function, but any examples I have found with probability for this use have been in C# or JS.

I don't have code yet

The end result is that the player clicks a button next to their skill, then the system randomly generates a list of 6 items that may be common, uncommon or rare with common items being the most common to come up and rare the least common. The player will then select the items they want off of that list; for example if a player has a 3 in Search they can pick 3 items off the list, if it is a 4 then they can choose 4 items. Finally, they would click a button that accepts/confirms the selections they have made and sends it to an inventory screen where it is saved.




Aucun commentaire:

Enregistrer un commentaire