美文网首页
Unity 随机种子

Unity 随机种子

作者: CERI_CHANNEL | 来源:发表于2022-07-31 11:16 被阅读0次
    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;
        }
    }
    

    每次随机的值都是一定的

    相关文章

      网友评论

          本文标题:Unity 随机种子

          本文链接:https://www.haomeiwen.com/subject/lyqrwrtx.html