【发布时间】:2012-07-20 16:26:51
【问题描述】:
以下伪代码将如何转换为 Python?
function IntNoise(32-bit integer: x)
x = (x<<13) ^ x;
return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 7fffffff) / 1073741824.0);
end IntNoise function
我不确定以下项目:IntNoise 调用中的 32-bit integer: x 参数; << 和 &7fffffff。
该函数是来自此网页的随机数生成器:Perlin Noise。
【问题讨论】:
-
仅供参考,python 有一个内置的随机数生成器:docs.python.org/library/random.html
-
s/function/def/, s/IntNoise/int_noise/, s/32-bit integer: //,在第一行末尾加一个冒号,在 7fffffff 前面加上 0x,去掉最后(“结束”)行。
标签: python pseudocode