> Hi;
> I am using SysRandom to generate random numbers. It is really giving me fits
> in that I am not getting true random numbers. For one I am using it to
> shuffle cards. I see a flush very often with a pattern. Shuffling and
> dealing gives me the same hands over time way more than is natural.
> I have tried the following:
> 
> SysRandom(0)%52
> SysRandom(TimGetSeconds())%52
> 
> I have also tried using static vars to remember last rand num and use it as
> a seed. I am using GCC.
> Does anyone know a good way to make this more random? Any pointers
> appreciated (no pun intended :)
> -Jim.

  try this:

---
void
randomize()
{
  SysRandom(TimGetTicks());
}

Byte
random()
{
  return (Byte)SysRandom(0);
}
---

  when you have '0' it uses the last seed it generated. use the
  randomize at the start of your program, and technically, every
  time you start it.. it should reset to a different seed.

  dont know how this will affect your card dealing.. maybe %52
  is a bad case for the number generator? :)

  cheers.

az
--
Aaron Ardiri 
Lecturer                       http://www.hig.se/~ardiri/
University-College i G�vle     mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN       
Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
Mob: +46 70 352 8192           A/H: +46 26 10 16 11

Reply via email to