ID:152275
 
Can decimal numbers be correctly intepretted in prob()?
Just use rand()
if(rand(1,1000)==1)
In response to Xx Dark Wizard xX
Isn't rand() being "faded out"?
In response to Tweelik
No.
In response to Xx Dark Wizard xX
No, use prob.
In response to Audeuro
He can't when he wants decimals. Or he could use a custom one like,
proc
xproc(val)
return rand(1,100/val) = 1
In response to Xx Dark Wizard xX
He can get close enough. It's still better than using rand().
In response to Audeuro
Is that speed wise, readability-wise, or both?

I always wondered how fast "if(!rand(0,175))" would be compared to the standard methods.
In response to DarkCampainger
Both. prob is built for this type of stuff, and you don't have to do any extra work to figure out what chance you want.
Tweelik wrote:
Can decimal numbers be correctly intepretted in prob()?

Yes.
In response to Foomer
When in doubt, test!
var
total
success1
success2
success3

mob
Stat()
statpanel("Progress")
stat("prob(50)", "[success1]/[total] = [success1/total*100]%")
stat("prob(50.5)", "[success2]/[total] = [success2/total*100]%")
stat("prob(50.05)", "[success3]/[total] = [success3/total*100]%")

New()
..()
spawn()
if(!total)
var/T = total+1
while(T!=total) // while BYOND can track the numbers accurately
total = T
T++
if(prob(50)) success1++
if(prob(50.5)) success2++
if(prob(50.05)) success3++
sleep()
world << "prob(50) \tdifference = [100*(success1/total - 0.5)/0.5]%"
world << "prob(50.5) \tdifference = [100*(success2/total - 0.505)/0.505]%"
world << "prob(50.05) \tdifference = [100*(success3/total - 0.5005)/0.5005]%"

Sorry for ever doubting you, Foomer, but I had to see for myself.
In response to Shadowdarke
Wow, you sure overcomplicated that. Mine was like 5 lines.