You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let seed = umul32_lo(x_uint, 0x1f1f1f1f) ^ z_uint;
let mt = new MersenneTwister(seed);
let n = mt.random_int();
this._isSlimy = (n % 10 == 0);
MersenneTwister() is actually calculation an array with a length of 624, but only the first 397 numbers are used. If you write this function manually and simplify unnecessary parts, it can be much faster.
I'm sorry that I can't use typescript language, but I can provide code in C language.
Here is my programming in C language, The correctness of the algorithm has been tested: https://github.com/origin0110/SlimeChunkFinder
uint32_t get_seed(int32_t x, int32_t z)
{
return x * 0x1f1f1f1f ^ z;
}
fast_t is_slime_chunk_mt(uint32_t s)
{
uint32_t m = 0x6c078965 * (s ^ s >> 30) + 1;
s = s & 0x80000000 | m & 0x7fffffff;
for (int i = 2; i < 398; i++)
m = 0x6c078965 * (m ^ m >> 30) + i;
m ^= (s >> 1) ^ ((-((int32_t)(s & 1))) & 0x9908b0df);
m ^= m >> 11;
m ^= m << 07 & 0x9d2c5680;
m ^= m << 15 & 0xefc60000;
m ^= m >> 18;
return (fast_t)(!(m % 10));
}
The text was updated successfully, but these errors were encountered:
I also simplified my Mersenne Twister after seeing this issue.
As a result, I ended up in almost the same place as Origin0110.
It just transforms the expression so it gives exactly the same result as the original.
Here is a pure JavaScript implementation.
MersenneTwister()
is actually calculation an array with a length of 624, but only the first 397 numbers are used. If you write this function manually and simplify unnecessary parts, it can be much faster.I'm sorry that I can't use typescript language, but I can provide code in C language.
Here is my programming in C language, The correctness of the algorithm has been tested:
https://github.com/origin0110/SlimeChunkFinder
The text was updated successfully, but these errors were encountered: