Page 1 of 1

Would like help creating an "odds system"

Posted: Wed Mar 04, 2009 1:17 pm
by picknmix
Hi all,
I'm programming a game of Chnace in PHP, but would like to know how to create a system whereby chances are involved.
As an example, let's just say i want:
x to have a 1 in 100 chance of appearing, y a 1 in 25 and z 1 in 2, and then anything else to be w.

Any help would be much appreciated,
-Andrew-

Re: Would like help creating an "odds system"

Posted: Wed Mar 04, 2009 1:48 pm
by mickeyunderscore
I usually use the rand() function if I want to set 'odds' of things happening. http://uk3.php.net/rand

Re: Would like help creating an "odds system"

Posted: Tue Mar 10, 2009 3:20 am
by picknmix
is there not a simpler way that random numbers and then putting
if...=1 then echo "reiutyei" else if...=2

Re: Would like help creating an "odds system"

Posted: Tue Mar 10, 2009 7:39 am
by Mark Baker
picknmix wrote:is there not a simpler way that random numbers and then putting
if...=1 then echo "reiutyei" else if...=2
I'd say definitely.... it all depends on what you actually want to do, which is something you haven't actually said