|
|
"Return Values Based on Probability ", by shaunsullivan
|
This include will allow you to add a number of possible outcomes (string, int or float), and assign each outcome a relative weight. Then, you can call a function that will return an outcome based on the weight.
For example:
prob_init() ; must call init prob_add_str(10,"shaun") prob_add_str(40,"collin") prob_add_str(50,"sam") local s = prob_roll_str()
; So with the above code it is 10% likely we'll return "shaun", 40% chance we'll return "collin" and 50% chance we'll return "sam" ;(note the weights are just relative, they need not add up to 100) |
| Code | | | |