Is there a name for this fetch algorithm used in Minicraft?

For Ludum Dare 22, Notch programmed a game after 48 hours called Minicraft. It looks like a two-dimensional micro.

In any case, the source is available (here: http://www.ludumdare.com/compo/ludum-dare-22/?action=preview&uid=398 ), and I watched since I was interested in random terrain generation and levels. There is a block of code in the code that starts the kernel generation, and the algorithm seems familiar to me, but I cannot give it a name. I would like to know exactly what it is so that I can learn more about it and find out how it works.

In particular, the code is at the Gen.java level:

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); 

These two loops use some sort of sampling algorithm, and I just wanted to know if this algorithm is known, or if it's easy to cut it.

+8
algorithm
source share
1 answer

It looks like a diamond-square algorithm.

+7
source share

All Articles