ID:169760
 
I've always used rand() in programming until recently I read on the forums that its better to use prob(). Can someone explain why this prob is better than rand()? Is it more robust? Better programming practice? etc etc.

~>Jiskuha
Jiskuha wrote:
I've always used rand() in programming until recently I read on the forums that its better to use prob(). Can someone explain why this prob is better than rand()? Is it more robust? Better programming practice? etc etc.

~>Jiskuha

It's just easier to say "Do something with a 40% chance" using prob then rand.
As far as effeciency is concerned I doubt there is much difference. Though when you use prob you make it more clear that it is a percentile chance. And making code which is easier to read means it is easier to spot bugs as well as other people spending less time figuring out what you are trying to do.