mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 09:39:36 +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
|
} // namespace
|
||||||
|
|
||||||
PolyglotBook::PolyglotBook() {
|
PolyglotBook::PolyglotBook() : RKiss(Time::now() % 10000) {}
|
||||||
|
|
||||||
for (int i = Time::now() % 10000; i > 0; i--)
|
|
||||||
RKiss.rand<unsigned>(); // Make random number generation less deterministic
|
|
||||||
}
|
|
||||||
|
|
||||||
PolyglotBook::~PolyglotBook() { if (is_open()) close(); }
|
PolyglotBook::~PolyglotBook() { if (is_open()) close(); }
|
||||||
|
|
||||||
|
|
|
@ -61,17 +61,15 @@ class RKISS {
|
||||||
return s.d = e + s.a;
|
return s.d = e + s.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init seed and scramble a few rounds
|
public:
|
||||||
void raninit() {
|
RKISS(int seed = 73) {
|
||||||
|
|
||||||
s.a = 0xf1ea5eed;
|
s.a = 0xf1ea5eed;
|
||||||
s.b = s.c = s.d = 0xd4e12c77;
|
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();
|
rand64();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
RKISS() { raninit(); }
|
|
||||||
template<typename T> T rand() { return T(rand64()); }
|
template<typename T> T rand() { return T(rand64()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue