Skip to content

Instantly share code, notes, and snippets.

@TylerLeite
Last active March 15, 2019 17:55
Show Gist options
  • Save TylerLeite/f5bdf255da587084a752 to your computer and use it in GitHub Desktop.
Save TylerLeite/f5bdf255da587084a752 to your computer and use it in GitHub Desktop.
Tiny RNG in c++
#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