mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 18:17:02 +08: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:
@@ -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()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user