Marcus Watts states:
Another way to fix this, is if you're using %, make sure the random
value you plug into % is smaller than the largest multiple. For 189,
that would be 22724694*189 or 4294967296U. If the number you get
is larger than this, discard it and obtain another random number.
Hi,
that is an interesting (off-)topic :-) May I ask the very last question?
If % is not good enough for getting random values in a range, then what is?
I see a lot of arc4random() % ... when grepping the /usr/src on OpenBSD.
And my (probably too naive) approach to shuffling 32 cards has been:
Alexander Farber [EMAIL PROTECTED] asks:
...
If % is not good enough for getting random values in a range, then what is?
...
Actually, % 32 is fine (or any reasonably small power of 2). Modulo
any odd number is guaranteed to have at least a small problem, and
module a large enough number is
Hello!
On Mon, Jul 18, 2005 at 11:02:54AM -0700, Jack Bates wrote:
[...]
4) Do not use the % (modulo) operator to select a card. The residues from
% introduce small amounts of bias, and this is a disqualifying factor for
regulated gaming.
Does that point still hold, assuming I use a modulus
Hi,
I'm developing a small multiplayer card game on OpenBSD
(but also try to keep it at least compilable on Linux).
After 32 cards have been shuffled, each of 3 players gets
10 cards. At the moment I use the sum of time()s when any
data has been received from a player as the seed value:
Artur Grabowski wrote:
A good suggestion might be to use arc4random(3) instead of random(3).
If the security of your application depends on randomness, you should
really pay an expert to help you do it. Randomness is harder than it
looks and most likely you will screw it up very badly (a few
Said Outgajjouft [EMAIL PROTECTED] writes:
Can you actually only use software code to achieve true randomness?
Who cares?
You don't need true randomness. You need good enough. What good
enough is depends on your application, the potential threats, the
sophisitcation of the attackers, the other
Thank you for both good advices.
Until I have money to pay an expert and my card game isn't using real money...
Would arc4random() % 32 be the usual way to get random integers from 0 to 31,
or are some bits of the returned value more random than the others?
And what is the highest number
Alexander Farber [EMAIL PROTECTED] writes:
And what is the highest number returned by arc4random(), is it RAND_MAX?
The man page doesn't elaborate on this subject
32 bits.
//art
Alexander Farber wrote:
Hi,
I'm developing a small multiplayer card game on OpenBSD
(but also try to keep it at least compilable on Linux).
After 32 cards have been shuffled, each of 3 players gets
10 cards. At the moment I use the sum of time()s when any
data has been received from a
Good day:
I happen to be very familiar with this subject, having developed, analyzed
and qualified two different card-shuffling algorithms for real-money play
in the online card game business. There is a fair bit of literature on
this subject.
Some tips that I can share without breaking an NDA:
11 matches
Mail list logo