Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:23:08+00:00 2026-05-27T16:23:08+00:00

For Ludum Dare 22, Notch programmed a game in 48 hours called Minicraft. It’s

  • 0

For Ludum Dare 22, Notch programmed a game in 48 hours called Minicraft. It’s like a 2D minecraft.

Anyway the source is available (here: http://www.ludumdare.com/compo/ludum-dare-22/?action=preview&uid=398 ), and I was taking a look since I am interested in random generation of terrain and levels. In the code is a block of code which runs the core generation, and the algorithm to me seems familiar, but I can’t put a name to it. I’d like to know exactly what it is so I can read more about it and learn how it works.

Specifically, the code is from 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);

Those two for loops are running some kind of sampling algorithm, and I would just like to know if this is known named algorithm, or if notch just rolled his own.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:23:09+00:00Added an answer on May 27, 2026 at 4:23 pm

    This looks like the diamond-square algorithm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just finished my entry for the 14th Ludum Dare 48-hours game making competition
I recently watched a bit of Notch's Ludum Dare live stream. He uses Eclipse's
Every time I look at some Java source code, I find myself surfing in
I am using Capistrano to deploy a ruby on rails project. I am attempting
We are developing a J2ME application and sometimes we face constraints while working with
I have a program that needs to create a text log. In XP, everything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.