Hello,
first I have to say, my english isn't very well so just try to understand it
;-).
I've got a little problem with the PHP function rand().
I want to create a little programm which simulate a "roulette" game (you
know this stupid game you can play in a casino :) ).
But it is impossible to simulate such a game with a simple rand() function.
Of course I initilize the random generator with the program start, with
srand().
But fact is, that, in a roulette game, the probability for each game is the
same (for example: 1/37 for a simple number like '4' or '28').
So I tried to put 37 items in an array called numbers[] and start the random
generator with numbers from 0 to 36 and echoed the item to the screen.
But if I put this system into e loop and try to simulate about 1000 games I
evidently get e "Laplace" experiment.
But this is the fault. Statistic fails in a roulette game, I think. Do it?
I think the ball has no "brain" so the probability is the same for each
game. In fact it is possible that I get one number 50 times. But with the
random generator, which is obviously too good, it won't work. What can I do?
Thanks for help
Martin
first I have to say, my english isn't very well so just try to understand it
;-).
I've got a little problem with the PHP function rand().
I want to create a little programm which simulate a "roulette" game (you
know this stupid game you can play in a casino :) ).
But it is impossible to simulate such a game with a simple rand() function.
Of course I initilize the random generator with the program start, with
srand().
But fact is, that, in a roulette game, the probability for each game is the
same (for example: 1/37 for a simple number like '4' or '28').
So I tried to put 37 items in an array called numbers[] and start the random
generator with numbers from 0 to 36 and echoed the item to the screen.
But if I put this system into e loop and try to simulate about 1000 games I
evidently get e "Laplace" experiment.
But this is the fault. Statistic fails in a roulette game, I think. Do it?
I think the ball has no "brain" so the probability is the same for each
game. In fact it is possible that I get one number 50 times. But with the
random generator, which is obviously too good, it won't work. What can I do?
Thanks for help
Martin
Comment