Re: virtual coin toss 55%
| From: | Richard Baskett | Date: | Sat, 18 May 2002 05:18:46 +0000 |
| Subject: | Re: virtual coin toss 55% | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98228@lists.php.net to get a copy of this message | ||
I want to say right from the beginning that there is a better way of doing
this, but this will work :)
Just keep track of what the user has thrown so far and do a check on it.. So
that if it's less than 45% change the flip to what the user picked.. If that
will put it over 45% then make it opposite what the user picked.. This will
let the user win very close to 45% every single time.
Or you could do a weight scale.. To make the average user win 45% of the
time instead each user.. So:
Grab a random number between 1 and 100;
If ($number >=1 && $number <=45) $user = 'Wins!' // num between 1 and 45
If ($number >=46 && $number <=100) $user = 'Loses!' // num between 46-100
So basically the user has a 45% chance of winning while the operator has a
55% chance :)
I know there are better ways, but this will give you an idea :)
Rick
"We do not have to visit a mad house to find disordered minds; our planet is
the mental institution of the universe." - Unknown
> From: "Randy Johnson" <php@icecoldgold.com>
> Date: Fri, 12 Apr 2002 01:07:53 -0400
> To: <php-general@lists.php.net>
> Subject: [PHP] virtual coin toss 55%
>
> I was surfing the internet today and found a site that offered a coin toss
> game in PHP. The site claimed that it used the latest and most random
> computer algorithms to do the Coin Toss.
>
> In the next line it said that you (the player) would win 45% of the time.
>
> I would like opinions how somebody could offer a 50/50 coin toss game and
> gurantee a 45% win ratio for the player
>
> The idea of game programming is appealing, but I have no idea how you would
> gurantee that the player wins 45% of the time and the operators win 55% of the
> time.
>
>
> Thanks in advance
>
> Randy
>
>
>
>
>