Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm Minicraft中使用的这种采样算法有名字吗?_Algorithm - Fatal编程技术网

Algorithm Minicraft中使用的这种采样算法有名字吗?

Algorithm Minicraft中使用的这种采样算法有名字吗?,algorithm,Algorithm,对于Ludum Dare 22,Notch在48小时内编写了一个名为Minicraft的游戏。它就像一艘2D地雷船 无论如何,源代码是可用的(这里:),我正在看一看,因为我对随机生成地形和标高感兴趣。代码中有一段代码运行核心生成,算法对我来说似乎很熟悉,但我不能给它起个名字。我想知道它到底是什么,这样我就可以阅读更多关于它的信息,了解它是如何工作的 具体来说,代码来自levelGen.java: do { int halfStep = stepSize / 2;

对于Ludum Dare 22,Notch在48小时内编写了一个名为Minicraft的游戏。它就像一艘2D地雷船

无论如何,源代码是可用的(这里:),我正在看一看,因为我对随机生成地形和标高感兴趣。代码中有一段代码运行核心生成,算法对我来说似乎很熟悉,但我不能给它起个名字。我想知道它到底是什么,这样我就可以阅读更多关于它的信息,了解它是如何工作的

具体来说,代码来自levelGen.java:

    do {
        int halfStep = stepSize / 2;
        for (int y = 0; y < w; y += stepSize) {
            for (int x = 0; x < w; x += stepSize) {
                double a = sample(x, y);
                double b = sample(x + stepSize, y);
                double c = sample(x, y + stepSize);
                double d = sample(x + stepSize, y + stepSize);

                double e = (a + b + c + d) / 4.0 + (random.nextFloat() * 2 - 1) * stepSize * scale;
                setSample(x + halfStep, y + halfStep, e);
            }
        }
        for (int y = 0; y < w; y += stepSize) {
            for (int x = 0; x < w; x += stepSize) {
                double a = sample(x, y);
                double b = sample(x + stepSize, y);
                double c = sample(x, y + stepSize);
                double d = sample(x + halfStep, y + halfStep);
                double e = sample(x + halfStep, y - halfStep);
                double f = sample(x - halfStep, y + halfStep);

                double H = (a + b + d + e) / 4.0 + (random.nextFloat() * 2 - 1) * stepSize * scale * 0.5;
                double g = (a + c + d + f) / 4.0 + (random.nextFloat() * 2 - 1) * stepSize * scale * 0.5;
                setSample(x + halfStep, y, H);
                setSample(x, y + halfStep, g);
            }
        }
        stepSize /= 2;
        scale *= (scaleMod + 0.8);
        scaleMod *= 0.3;
    } while (stepSize > 1);
do{
int halfStep=步长/2;
对于(int y=0;y1);
这两个for循环正在运行某种类型的采样算法,我只想知道这是已知的命名算法,还是notch自己的算法。

这看起来像