Random Map Generation

[quote="Damocles,post:18,topic:37886"]
/*
simple Island generator by Damocles
*/

[/quote]
That is basicly just “noise” applied to increasingly smaller segments? That’s a pretty nifty idea as well. Looks good, that would be like 10 passes for an 1024x1024 field right? (2^10), +10 for smoothing would be about 20 passes. I think mine has about as many passes, but yours is probably better if you want to expand the map.

Sorry, but I’m still a beginning programmer, just finding out about all this stuff. Where do you guys aquire this knowledge? Is it something that builds up over time, or are there sites/books that are bundles with usefull information like this? I’m currently reading into the “Value Noise” you talked about, and I think that would be usefull for terrain generation.

IMHO: Value noise isn’t of great interest. You’d probably should use Perlin gradient noise.

You have got to agree his terrain has a unique feel. Value noise and perlin noise typically look rather boring and unnatural, unless it’s finetuned into oblivion.

In the end what counts is how the result looks like.
No need for academic discussions on that.

BTW: how can terraingeneration be inperformant, that not a realtime application, the performce does not
matter there. Be it 1 or 3 seconds at initial worldgeneration, noone cares.

Well, I want to add new terrain in real time, but I guess if I’d for example add chuncks of like 32x32 at a time, that that should be still very doable in real time. So well yes, it doesn’t matter at all haha :P. Sometimes I just have no idea where I’m going

no was directed at Roquen’s post.

Anyhow, there are many good tutorials online. And since your voxel-cube rendering looks good already, you should be able to
make a nice terrain in no time.

The circular terrain still looks good. Maybe you can leave it in to be applied at some parts of your world.

I’m not drawing voxel-cubes or anything, it’s just images. Here’s an image of the world upclose, that was just a version of the game with smaller images:

http://img502.imageshack.us/img502/4607/gamece.png

Currently breaking my head on building a system to load tile variations from a file so that I can just change a text file for different graphics instead of code. It’s ussually the basic stuff that gets me stuck, Java always mock me like that, with stuff like LOL YOU LOADED AN IMAGE, AND I CAN DISPLAY THE WIDTH OF THAT IMAGE FOR TESTING PURPOSE, BUT THERE’S NO WAY I AM GOING TO DRAW THAT ON SCREEN.

Sorry for the rambling, after I have the system done, I will get back to terrain generation, and I can share with you my silly ideas of treeplanting, and rockplacing on the map. That is, if anyone is interested.

Oooh I’m interested! Keep sharing your silly ideas because I love them :slight_smile: I’ve been quietly lurking this thread because random map generation has always amazed and baffled me :slight_smile:

Hey, I’m back with some more not-really related stuff. But while making this I was thinking IT’S KIND OF BORING TO HAVE THE SAME GRASS TILE ALL THE TIME. So I said to my spritedrawing friend DO THOSE SPRITES AGAIN BUT NOW WITH FLOWERS AND LITTLE POOLS OF MUD. And he did (Thanks :smiley: ), so then I had to make some way to get the flowers in game, which COULD mean I would have to hardcore all the sprites and blah blah, but I thought that would not be very good for development of the game later on, so instead I create this sytem, where the only thing I have to do to get a tile ingame, with a couple of variations, is this:

tType[3]=new TileResource("Grass"); 

So you might be thinking, but how does it load all it’s information? Well, I simply have a file grass.props, that has this text:

Name=Grass
Height=0
Images=5
Image1=Grass.png
Image1Freq=800
Image2=Grasshole.png
Image2Freq=5
Image3=Grasshole2.png
Image3Freq=5
Image4=Grasshorseflower.png
Image4Freq=100
Image5=Grasshorseflower2.png
Image5Freq=100

So from that I just load the props, and images, this way instead of having to think and try how many percent of my grass I want all happy with flowers, I can just tell my graphic designing friend, to do that stuff.

Tl;dr: I am lazy and post stuff not related to Map Generation to a map generation thread, here’s a pretty picture of my work:

http://img4.imageshack.us/img4/3558/prwettyflowers.png

Nice. Just need a bit of texture splatting and you’re all set.

Today was tree planting day. At first I was like, OKAY GIVE EVERY TILE A TREE WITH A CHANCE of 0.5, but that looked but ugly, so I thought of something else. I changed up my “Map generator” a bit so that instead of giving out “Tiles” it gives out a value between one and hundred, and I do the title choosing in my “TileGrid” class (which makes a lot more sense).

Now, to plant my trees, I seeded another world, and used the values of the mapgenerator to choose where to place trees. This way, just like I use the map generator to make water appear together, with sand at the edges, I now use it to make trees appear together, with bushes along the edges. It works pretty fine! Here is a screenshot of the world zoomed out:

http://img534.imageshack.us/img534/3538/unzoomedwithtrees.png

As you can see the trees form nice little woods! Which is pretty cool.

I also split all the parameters of my map generation so that I can easily load different “prefabs” for different terrains, and I added another bit to the terrain creation, for more randomization, which is what I dubbed “Cliff” generation, it works kind of like this:

    
//For the amount of times I want to add a "Cliff"
for(int i=0;i<cliftimes;i++)
    {
      //Choose random point
      pointX=genValue(WIDTH);
      pointY=genValue(HEIGHT);

      //Choose random "intensity" depending on the parameter "Clifmult"
      mult=genValue(clifmult);
      //For every point
      for(int x=0;x<WIDTH;x+=1)
      {
        for(int y=0;y<HEIGHT;y+=1)
        {
          int t=distance(x,y,pointX,pointY);
          //This time instead of doing the Cos( ), I do a 2/(.5*(t+1)), so it's basicly a formula of the shape 1/t, which results in a nice and high peek!
          value[x][y]+=(int)(5*mult*(2/(.5*(t+1)))+mult*5*(1/(t+1)*Math.sin(t/5+90)));  
        }
      }  
    }  

This piece of code makes it possible to create nice islands, here’s an example of my island biome:

http://img710.imageshack.us/img710/3893/uglyislands.png

As you can see, the cliff script is still, pretty ugly, I circled in red the ugly sudden rock formations it creates so I will have to tweak that to make it better. My goal with this addition is to make it possible for cliffs to appear next to the water (So that I can later add pretty waterfalls), but it isn’t working yet : (. I’m thinking of doing something with “Erosion”, evening out the low slopes, and extremizing the high slopes, but I’ll have to look into that

Here is my swamp “biome” which does look pretty:

http://img839.imageshack.us/img839/7343/swamp.png

It’s “initialization” code looks something like this:

      //SWAMP
      case 3:
      //"random" multiplier, decides the randomness
      ranmult=50;
      //Laketimes and lakemult determines the number of "Lake" constructions (The Cos(t)-Cos(.5t)) itterations
      laketimes=12;
      lakemult=10;
      //Determines the amounts of cliffs, which is still 0 since they are ugly
      cliftimes=0;
      clifmult=0;
      //How many times to Anti-alias
      aatimes=5;
      break;

:open_mouth: That looks beautiful!

“Texture splatting” has also been added, but I just have graphics for all the edges (:

Yes it does, here’s a picture of it up close

http://img850.imageshack.us/img850/5175/beautyo.png

Really happy with my the artwork, it’s very enjoyable working with such quality sprites, crafted to my specifications.

Finally! I really wanted a top-down 2D version of Minecraft and Terraria! Now we have all dimensions and angles covered! =D Really beautiful!

I felt rather unhappy with my map generation, in terms of making it possible to create infinte maps with it, so I decided to try something completely else!
It’s a bit based on what Damocles is doing, here is what the code about looks like to give an idea:


  public double getAAPoint(int x, int y, int aa)
  {
    //Base case
    if (aa<=0) return getPoint(x,y);
    //Calculate a "stepsize", which is kind of like how big the cell I'm using is
    double stepsize=Math.pow(2,aa);
    //return the top left corner of my current rectangle and call this function again with a lower "aa" which results in a lower stepsize
    return(getPoint((int)(x/stepsize),(int)(y/stepsize))
           +getAAPoint(x,y,aa-1));
  }

  public int getPoint(int x, int y)
  {
    //Returns a seeded random variable, between 0 and 100
    return rand.random(x*x-y,100);
  }

So for example getAAPoint(x,y,7), would first take the value of the left upper corner of a 128x128 square (2^7-*), (As do all points in this rectangle!), next I do the same for the 64x64 square this is in, then for the 32x32 square it is in, then 16x16, 8x8, 4x4, 2x2 1x1. I think you’ll get what I mean, although my explanation is really vague. At the moment it looks reallllly shitty :P, but I’m sure that with more work, and maybe a tad of AA it is going to look good:

http://img17.imageshack.us/img17/6169/rectanglerecursion.png

The square structure is reaally easy to spot at the moment, but oh well! I’m thinking of maybe trying something like this with circles or something, although I have no idea how I would subdivide the map in circles, but it seems like a funny idea, and in my opinion, as a hobby, programming has to remain fun.

try to have the value have more impact (bigger factor), the smaller the “stepsize” is.

Thus the large features having the lowest impact.

With some smoothing, it should look much better also, and removes the large seams along the
bigger squares.

I’m making progress! I will show my progress in pictures, because a picture speaks a thousand words and stuff:

http://img683.imageshack.us/img683/3295/circley.png

That was my first step, within every square, I choose a point, and I then draw circles arround it using sin(distance to the point). This looks incredibly shitty! Hooray, but now we add another circle, in a smaller rectangle, half the size the other one, and we get the following:

http://img24.imageshack.us/img24/2144/circle2u.png

So that’s already looking a bit better, but still has a lot of jagged edges and uglyness, but I thought OH WHATEVER, JUST DO THAT A LOT OF TIMES AND I"LL SEE WHAT IT LOOKS LIKE.

http://img688.imageshack.us/img688/6494/nomorecircle.png

Somehow it looks pretty good, don’t ask me about the theory behind it. I’m now trying to aproximate how the map looked before with this new method. I think with some smoothing I can get pretty near, but I have so far not used smoothing.

The benefit of the new method is, that I just have a function getMapPoint(x,y) that returns the height of a point on the map, without requiring any prior knowledge on the map or anything. It’s fast too! I’m still thinking about how I’m going to do the smoothing fast.

Taking a regular shape and iterating it a bunch of times randomly = chaotic result. Just what you want in terrain.

Actually if you applied a bit of erosion to the second map, you’d get a pretty nifty bog with lots of lagoons.