Terrain Generator

I wrote a terrain generator in Java the other day, inspired by several discussions. Here are some screenshots:

screenshot 1 screenshot 2

The algorithm is roughly as follows:

  • We start with a map comprised of large blocks. The default block size is 64 by 64. The state of each block (land or water) is entirely pseudorandom.
  • Repeat until all blocks are 1 by 1 in size:
    • Divide each block into four smaller blocks.
    • For each derived block, decide on a probability for that block becoming a land block. This probability is based on the state of the block it was derived from, and the land mass of surrounding blocks. The probability computation can be configured in different ways with different weights.
    • If a pseudorandom number between 0 and 1 is less than that probability, the derived block becomes a land block. Otherwise, it becomes a water block.
  • Darken land blocks which are contiguous with water blocks.

Here is a runnable JAR to play around with. You can also view the source code, although it may be difficult to understand the algorithm from the code alone.

Posted in Java by Daniel at December 25th, 2009.
Tags: , ,

18,710 Responses to “Terrain Generator”

  1. Visitor recommendations…

    [...]one of our visitors recently recommended the following website[...]……

  2. Awesome website…

    [...]the time to read or visit the content or sites we have linked to below the[...]……

  3. Gems form the internet…

    [...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……

  4. Thyromine says:

    You should check this out…

    [...] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well [...]……

  5. You should check this out…

    [...] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well [...]……

  6. hgh says:

    Gems form the internet…

    [...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……

  7. make money says:

    Websites you should visit…

    [...]below you’ll find the link to some sites that we think you should visit[...]……

  8. bill says:

    Sites we Like……

    [...] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose [...]……

  9. aquaponic says:

    Recent Blogroll Additions……

    [...]usually posts some very interesting stuff like this. If you’re new to this site[...]……

  10. groceries says:

    Related……

    [...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……

Leave a Reply

You must be logged in to post a comment.