Last active
March 15, 2019 17:55
-
-
Save TylerLeite/f5bdf255da587084a752 to your computer and use it in GitHub Desktop.
Tiny RNG in c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ctime> | |
class Random { | |
public: | |
Random(int seed=time(NULL)) : m_seed(seed) {} | |
//Return a random number from 0 to range-1 | |
int next(const int range){ | |
m_seed = (1028597*m_seed + 488249) % 1737017; | |
return m_seed % range; | |
} | |
protected: | |
int m_seed; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment