Unity 随机种子

2022-07-31  本文已影响0人  CERI_CHANNEL
public static int Random(ref uint seed)
{
    unsafe
    {
        uint next = seed;
        uint result
        next *= 1103515245;
        next += 12345;
        result = (uint)(next / 65536) % 2048
        next *= 1103515245;
        next += 12345;
        result <<= 10;
        result ^= (uint)(next / 65536) % 1024
        next *= 1103515245;
        next += 12345;
        result <<= 10;
        result ^= (uint)(next / 65536) % 1024
        seed = next;
        return (int)result;
    }
}

每次随机的值都是一定的

上一篇下一篇

猜你喜欢

热点阅读