Incorrect random number generation in Tali
Bug #512636 reported by
Eric Lance
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNOME Games |
Fix Released
|
Medium
|
|||
gnome-games (Ubuntu) |
Fix Released
|
Low
|
Unassigned |
Bug Description
Binary package hint: gnome-games
The function for generating the dice rolls does a simple modulus calculation, as shown below:
int
RollDie (void)
{
return ((rand () % 6) + 1);
}
However, this isn't really a good way to generate a random number. The low order bits aren't very 'random' in a linear congruential generator and if RAND_MAX doesn't divide evenly into 6 the distribution won't even be uniform.
Another method would be:
int
RollDie (void)
{
double r = rand() * (1.0 / RAND_MAX);
return (int)floor(r *6.0) + 1;
}
This might also fix issues mentioned in bug #164684.
Changed in gnome-games: | |
status: | Unknown → New |
Changed in gnome-games: | |
status: | New → Fix Released |
Changed in gnome-games: | |
importance: | Unknown → Medium |
To post a comment you must log in.
This bug is an upstream one and it would be quite helpful if somebody experiencing it could send the bug the to the people writing the software. You can learn more about how to do this for various upstreams at https:/ /wiki.ubuntu. com/Bugs/ Upstream/ GNOME . Thanks in advance!