Incorrect random number generation in Tali

Bug #512636 reported by Eric Lance
8
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.

Revision history for this message
Pedro Villavicencio (pedro) wrote :

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!

Changed in gnome-games (Ubuntu):
importance: Undecided → Low
Revision history for this message
Robert Roth (evfool) wrote :

Thank you for your bug report. This bug has been reported to the developers of the software. You can track it and make comments at: https://bugzilla.gnome.org/show_bug.cgi?id=621182

Changed in gnome-games:
status: Unknown → New
Revision history for this message
Pedro Villavicencio (pedro) wrote :

thanks for sent it upstream.

Changed in gnome-games (Ubuntu):
status: New → Triaged
Changed in gnome-games:
status: New → Fix Released
Revision history for this message
Martin Mai (mrkanister-deactivatedaccount-deactivatedaccount) wrote :

This should be fixed in Ubuntu 10.10 now. Thanks for reporting.

Changed in gnome-games (Ubuntu):
status: Triaged → Fix Released
Changed in gnome-games:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.