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-
Would like help creating an "odds system"
Moderator: General Moderators
-
mickeyunderscore
- Forum Contributor
- Posts: 129
- Joined: Sat Jan 31, 2009 9:00 am
- Location: UK
Re: Would like help creating an "odds system"
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"
is there not a simpler way that random numbers and then putting
if...=1 then echo "reiutyei" else if...=2
if...=1 then echo "reiutyei" else if...=2
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Would like help creating an "odds system"
I'd say definitely.... it all depends on what you actually want to do, which is something you haven't actually saidpicknmix wrote:is there not a simpler way that random numbers and then putting
if...=1 then echo "reiutyei" else if...=2