Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Height-Map generator that I made  (Read 7105 times)

Kesc

  • Bay Watcher
    • View Profile
Height-Map generator that I made
« on: December 04, 2011, 07:21:53 am »

t's been a time that I'm looking for an algorithm that generates a random new world map in a not-very-big tile map. None of those that I found satisfied me, so I made a new one.

What it does: It generates - inside a 70x70 map - a island or complex of islands by drawing rectangles with random sizes from a starting point, the root. As the rectangles have their dimensions altered, so is the Root position. Each generation creates a new rectangle, that adds 1 value to the tiles in its area, as the tile's value gets bigger, its representation on the map is changed:
0 -> _(The sea);
Between...
00 and 08 -> 1;
08 and 16 -> 2;
16 and 32 -> 3;
32 and 64 -> ^;
Beyond 64-> *(rare)

I pretend to insert one generation of the cellular automata algorithm to make the map smoother, but I thought it would be a good idea to ask here for more interesting and better ways to improve the map.

My next objective is fixing the map with cellular automata, insert one or two more roots to create another island and create an OPENGL output.

Here's a sample:


Here is the whole project - MS Visual C++ - , including source-code, of course. Feel free to improve it, distribuite it, do wathever you want as long as you share it here. :D
http://www.4shared.com/file/Pl8ES8r8/Tile_map_generator.html

It may not work in some OS.
Logged

G-Flex

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #1 on: December 04, 2011, 07:29:42 am »

Since you made a new topic instead of moving the old one for some reason, I'll just paste in what I said last:

Outputting this using text like this doesn't seem like a great idea to me because the resolution is extremely low. Values range from 0 to 64+, but there are only five possible values for representing height. I would recommend outputting as some sort of greyscale bitmap instead.

You mentioned something about "map drawer multiples" but I have no idea what you meant by that.
Logged
There are 2 types of people in the world: Those who understand hexadecimal, and those who don't.
Visit the #Bay12Games IRC channel on NewNet
== Human Renovation: My Deus Ex mod/fan patch (v1.30, updated 5/31/2012) ==

malloc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #2 on: December 04, 2011, 08:04:15 am »

So I have to ask the question: why not just use some modified perlin noise generator to generate the height map?
Logged

Kesc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #3 on: December 04, 2011, 08:20:38 am »

Since you made a new topic instead of moving the old one for some reason, I'll just paste in what I said last:

Outputting this using text like this doesn't seem like a great idea to me because the resolution is extremely low. Values range from 0 to 64+, but there are only five possible values for representing height. I would recommend outputting as some sort of greyscale bitmap instead.

You mentioned something about "map drawer multiples" but I have no idea what you meant by that.

The program adds 1~3 points to the rect's area, when it gets bigger than 8, its representation in the output changes from "1" to "2", when it gets bigger than 16 then its "3" and so on.

So I have to ask the question: why not just use some modified perlin noise generator to generate the height map?

The Perlin noise used for not-very-defined tile maps isn't so great.
The result didn't satisfied me, plus, it was much funnier creating a new method. :P
Logged

hawkeye_de

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #4 on: December 04, 2011, 08:21:18 am »

do you wanna make the height-map for fun or do you plan to develop a roguelike ? The libtcod library has also a nice API to create heightmaps.
Logged
"No matter what you or anyone else does, there will be someone who says that there's something bad about it. Whenever somebody comes up with a good idea, there's somebody else who has never had a good idea in his life who stands up and says, "Oh, you can't do that..."

-Tom Clancy

Kesc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #5 on: December 04, 2011, 08:29:40 am »

do you wanna make the height-map for fun or do you plan to develop a roguelike ? The libtcod library has also a nice API to create heightmaps.

Developing a roguelike, for fun. I'll use de PDCurses to add graphics(Coloured ASCII-text).
Logged

malloc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #6 on: December 04, 2011, 11:04:22 am »

The Perlin noise used for not-very-defined tile maps isn't so great.
The result didn't satisfied me, plus, it was much funnier creating a new method. :P

What are you talking about? You actually made me go program a little heightmap generator just for the sake of testing it out what I said.
This generates a map based on the fomular:
Perlin(x,y)*255*cos((dist(x,y)*PI)/255) for dist(x,y) < 128
Color coded for giggles.





Perlin noise can generate some cool islands, even for not so well defined maps.
« Last Edit: December 04, 2011, 11:09:48 am by malloc »
Logged

Kesc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #7 on: December 04, 2011, 11:26:27 am »

The Perlin noise used for not-very-defined tile maps isn't so great.
The result didn't satisfied me, plus, it was much funnier creating a new method. :P

What are you talking about? You actually made me go program a little heightmap generator just for the sake of testing it out what I said.
This generates a map based on the fomular:
Perlin(x,y)*255*cos((dist(x,y)*PI)/255) for dist(x,y) < 128
Color coded for giggles.





Perlin noise can generate some cool islands, even for not so well defined maps.


Damnit, you're right...
...Better late than never.


Well guys, I added 3 more roots with total random starting position, makin it look more like a continent. But since the Perlin noise is simpler and better than I expected, things probably'll be changed, but here's a result:


Next step is make the biomes by using the whittaker diagram as a reference:


The higher the place and as far as he gets from the equator line, the colder it gets. Also, the closer it gets from the sea, the bigger gets its moisture.

The map is going to be zoomed, 3x3 will be fractalized to 30x30.

After biomizing the whole map, it is time to build the cities - oh, they are modern -  with good starting points for cities and using probabilities to define which way the city will grow(For example, if on one side there's a ginormous mountain and on the other a safe forest, it'll grow to the forest's way. The city's starting point may be a church or a village next to resources(forests, deserts with oil, minerals). I still have to think about that...

The structure of the tile:
struct Tile {
   short int Height;     //Ranging from 1~5, ^ and *;
   short int Biome;      //There are 9 - the nineth is "developed city", where the climate is completely controled, as seen in the diagram;
                              //Maybe creating more vegetation and exotic animals would make it more interesting;
   short int Temp;      //The temperature in Celsius, simply said;
   short int Humidity;  //The name says everything;
   struct Constr;        //Tell us if there is a construction and its population
}


The Construction structure:
struct Constr {
   short int Building;    //The building in the tile, 0 means no building and therefore, no population;
   short int Pplation;   //How many people there are in this tile. If it is a residential zone, it says how many are living. If a comercial/industrial,
                              //how many are working. Other special buildings works the same way the C/I tile;
   short int Polution;   //Simply said, the average pollution of the area. Defined by industrial zones;
   short int Safety;     //Defined by pooverty(Subdeveloped buildings). I/C zones tend to be more dangerous;
   unsigned short int Value; //The value of the area. Defined by safety, pollution, distance from C/I(if R) places and biome;
}

As you guys can see, it was almost COMPLETELY based on SimCity, no coincidence. I thinked about taxes but you won't be living in the cities, just moving around and killing people, doing quests... Much like a rogue-like Grand Theft Auto.  :P

Any tips on the design, anything, just say it. I won't start programming all this stuff before having a good plan.
Spoiler (click to show/hide)
Logged

malloc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #8 on: December 04, 2011, 11:49:36 am »

Any tips on the design, anything, just say it. I won't start programming all this stuff before having a good plan.

Honestly it seems like you have a good idea for what you want. The way you described the design seems to make sense.

I would suggest you just program, there is no need to have a bulletproof plan for what you want. I mean minecraft never had a design document, just a developer who just had some simple visions for what he wanted and an enormous talent for programming.

If you want I can give you the my little map generator. It's written using the dreaded managed c++ Microsoft made, but you should be able to extract the perlin noise class and figure out how to use it.
Logged

klingon13524

  • Bay Watcher
  • The Mongols are cool!
    • View Profile
Re: Height-Map generator that I made
« Reply #9 on: December 04, 2011, 04:35:34 pm »

an enormous talent for programming.
Notch had a memory leak in Java. A MEMORY LEAK IN JAVA! I HAVE NO IDEA WHAT THAT IS OR WHY THAT'S SO SPECIAL, BUT IT'S APPARENTLY VERY IMPRESSIVE. WHY AM I SHOUTING?
Logged
By creating a gobstopper that never loses its flavor he broke thermodynamics
Maybe it's parasitic. It never loses its flavor because you eventually die from having your nutrients stolen by it.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: Height-Map generator that I made
« Reply #10 on: December 04, 2011, 04:47:57 pm »

an enormous talent for programming.
Notch had a memory leak in Java. A MEMORY LEAK IN JAVA! I HAVE NO IDEA WHAT THAT IS OR WHY THAT'S SO SPECIAL, BUT IT'S APPARENTLY VERY IMPRESSIVE. WHY AM I SHOUTING?
Impressive in a negative sense, yes.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

malloc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #11 on: December 04, 2011, 05:24:22 pm »

an enormous talent for programming.
Notch had a memory leak in Java. A MEMORY LEAK IN JAVA! I HAVE NO IDEA WHAT THAT IS OR WHY THAT'S SO SPECIAL, BUT IT'S APPARENTLY VERY IMPRESSIVE. WHY AM I SHOUTING?

Even with automatic garbage collection it's still possible to screw something up. Especially when dealing with loads of dynamic memory and data streaming.
Also, I did not say he had a talent for creating fool proof code, rather what I meant is he has a talent for outputting insane amounts of code without having any real plans, or at least that was my impression after watching him code for Ludum Dare.

Still considering he made a game which made him a millionaire, without having more than a list of features or "visions" for the game, I thing he must be doing something right.
Logged

G-Flex

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #12 on: December 04, 2011, 09:46:13 pm »

Still considering he made a game which made him a millionaire, without having more than a list of features or "visions" for the game, I thing he must be doing something right.

Or that he stumbled upon something that happened to work. Or, more likely, both.
Logged
There are 2 types of people in the world: Those who understand hexadecimal, and those who don't.
Visit the #Bay12Games IRC channel on NewNet
== Human Renovation: My Deus Ex mod/fan patch (v1.30, updated 5/31/2012) ==

malloc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #13 on: December 05, 2011, 06:27:08 am »

Still considering he made a game which made him a millionaire, without having more than a list of features or "visions" for the game, I thing he must be doing something right.

Or that he stumbled upon something that happened to work. Or, more likely, both.

Fine, I'll take it back, Notch does not have any programming talent. Happy?
Still, my point is, he can create something relatively good in the same timespand some people use on "planning" their games out.
The difference is that "planning" a game does not release a game.

Planning works well in working environments, not for small hobby game projects.
Logged

Kesc

  • Bay Watcher
    • View Profile
Re: Height-Map generator that I made
« Reply #14 on: December 05, 2011, 10:18:01 am »

Any tips on the design, anything, just say it. I won't start programming all this stuff before having a good plan.

Honestly it seems like you have a good idea for what you want. The way you described the design seems to make sense.

I would suggest you just program, there is no need to have a bulletproof plan for what you want. I mean minecraft never had a design document, just a developer who just had some simple visions for what he wanted and an enormous talent for programming.

If you want I can give you the my little map generator. It's written using the dreaded managed c++ Microsoft made, but you should be able to extract the perlin noise class and figure out how to use it.

If possible, I would really appreciate that.

I'm having some problems visualizing the process- for example, how exactly does the sin function smoothes the noise function? I still can't see it working, just formulas -, but I hope that interacting with it would answer my questions.
Logged
Pages: [1] 2