mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Allow to pass a 'seed' to RKISS
This somewhat simplifies the code. Suggested by Lucas Braesch. No functional change.
This commit is contained in:
parent
009a0f88e0
commit
896420b166
2 changed files with 4 additions and 10 deletions
|
@ -348,11 +348,7 @@ namespace {
|
|||
|
||||
} // namespace
|
||||
|
||||
PolyglotBook::PolyglotBook() {
|
||||
|
||||
for (int i = Time::now() % 10000; i > 0; i--)
|
||||
RKiss.rand<unsigned>(); // Make random number generation less deterministic
|
||||
}
|
||||
PolyglotBook::PolyglotBook() : RKiss(Time::now() % 10000) {}
|
||||
|
||||
PolyglotBook::~PolyglotBook() { if (is_open()) close(); }
|
||||
|
||||
|
|
|
@ -61,17 +61,15 @@ class RKISS {
|
|||
return s.d = e + s.a;
|
||||
}
|
||||
|
||||
// Init seed and scramble a few rounds
|
||||
void raninit() {
|
||||
public:
|
||||
RKISS(int seed = 73) {
|
||||
|
||||
s.a = 0xf1ea5eed;
|
||||
s.b = s.c = s.d = 0xd4e12c77;
|
||||
for (int i = 0; i < 73; i++)
|
||||
for (int i = 0; i < seed; i++) // Scramble a few rounds
|
||||
rand64();
|
||||
}
|
||||
|
||||
public:
|
||||
RKISS() { raninit(); }
|
||||
template<typename T> T rand() { return T(rand64()); }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue