Strike Force Heroes 2
The explosive sequel to the hit game Strike Force Heroes!
3.95 / 5.00 9,890 ViewsObsolescence
Defeat the enormous mechanical beasts--and become one of them.
4.02 / 5.00 45,581 ViewsHello there fellow Newgrounders, I have a question to ask about how to code Probability.
To be honest, I really have no idea how to do this, and have searched through the internet to find any useful information regarding this, but no luck.
How would you go about executing a function at lets say 23%?
Please point me in the right direction, and nothing too complicated is much appreciated.
_Revelance
Pick a random number between 1 and 100. Check 'if' the picked number, X, is below your threshold. So if you want 23% chance, then run your function if X is 23 or below.
You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.
if(Math.random() < .23){
function
}
Math.random() gives you a random value from 0 to 1. If that value is under .23, you are essentially dependent on the random value to determine the percentage of when the function should run.
Thank you very much guys, I appreciate it.