IceRandom.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /**
  3. * Contains code for random generators.
  4. * \file IceRandom.cpp
  5. * \author Pierre Terdiman
  6. * \date August, 9, 2001
  7. */
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. #include "../Opcode.h"
  11. using namespace IceCore;
  12. void IceCore:: SRand(udword seed)
  13. {
  14. srand(seed);
  15. }
  16. udword IceCore::Rand()
  17. {
  18. return rand();
  19. }
  20. static BasicRandom gRandomGenerator(42);
  21. udword IceCore::GetRandomIndex(udword max_index)
  22. {
  23. // We don't use rand() since it's limited to RAND_MAX
  24. udword Index = gRandomGenerator.Randomize();
  25. return Index % max_index;
  26. }