Would like help creating an "odds system"

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
picknmix
Forum Newbie
Posts: 2
Joined: Wed Mar 04, 2009 1:14 pm

Would like help creating an "odds system"

Post 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-
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: Would like help creating an "odds system"

Post by mickeyunderscore »

I usually use the rand() function if I want to set 'odds' of things happening. http://uk3.php.net/rand
picknmix
Forum Newbie
Posts: 2
Joined: Wed Mar 04, 2009 1:14 pm

Re: Would like help creating an "odds system"

Post by picknmix »

is there not a simpler way that random numbers and then putting
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"

Post 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
Post Reply