IceRandom.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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. // Precompiled Header
  11. #include "Stdafx.h"
  12. using namespace IceCore;
  13. void IceCore:: SRand(udword seed)
  14. {
  15. srand(seed);
  16. }
  17. udword IceCore::Rand()
  18. {
  19. return rand();
  20. }
  21. static BasicRandom gRandomGenerator(42);
  22. udword IceCore::GetRandomIndex(udword max_index)
  23. {
  24. // We don't use rand() since it's limited to RAND_MAX
  25. udword Index = gRandomGenerator.Randomize();
  26. return Index % max_index;
  27. }