Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 474 475 [476] 477 478 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 832022 times)

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7125 on: April 07, 2015, 03:04:22 pm »

Spoiler (click to show/hide)
:o
It looks nice, but the diamond-square algorithm doesn't seem to produce good mountain ranges. It tends to create swells at the center of continents, but doesn't produce a thin mountain range.
I'm not sure how toady made his mountains thin, maybe he used something to modify the map after generation to have the qualities that he wants for the mountains. Perhaps adding some sort of 'erosion' simulation that basically pushes back the mountains and makes them thiner could work.

But, before I try anything like that I want to try and get my moisture simulation working, and have the map be colored based on the biomes. I am thinking that it won't look as bad once the rest of the map has some more color.

Also, does anyone know anything that could be used as an alternative to huge nested if statements? I have some functions that are just huge because I cannot make them work any other way that I can see, and it sometimes makes them hard to understand, especially when debugging.
Logged

cerapa

  • Bay Watcher
  • It wont bite....unless you are the sun.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7126 on: April 07, 2015, 03:09:35 pm »

Depends on what those if's are?
Logged

Tick, tick, tick the time goes by,
tick, tick, tick the clock blows up.

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7127 on: April 07, 2015, 03:10:49 pm »

Helper functions? Pull out some of the duplicated code? As cerapa noted a lot of it depends on what exactly you are checking for.
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7128 on: April 07, 2015, 03:18:31 pm »

Actually, let me get back to you on that. I believe that I used helper functions whenever I could, but perhaps I didn't without thinking about it. I'll take another look. My idea for the past week is that I want to just get my basic model of terrain generation up, and that I would go back a make any specific changes once done. So, I may have missed a few things.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7129 on: April 07, 2015, 09:59:56 pm »

Adding continental plate modelling to the model can mix things up a bit. You're not going to get good looking tectonics with perlin/simplex alone. I'm basically thinking of creating a model where there is a polygonal, or grown regions which represent tectonic plates, then each one is given a motion vector. Where two plates have colliding motion vectors, you push up, where they pull apart, you push down. Probably give each edge an erosion factor, interpolated between vertexes so some mountain ranges are young (pointy) vs old (eroded). Layer this with the regular noise and you should get really nice mountain ranges.

About 4 years ago I was working on extending perlin terrain to spherical planets using cube-mapping. Basically you make a cube with meshes on the faces, then bulge out the vertexes to fit a sphere, and use 3D perlin noise, taking a spherical cross-section to get the height map. You can then tweak the vertexes up or down (from the center of the sphere) based on the height map. I'm thinking of updating it a tectonic plate system like I described.

BTW i came across this, which is a very interesting class of polyhedra for planet generation:

http://en.wikipedia.org/wiki/Goldberg_polyhedron

With these you can tesselate a sphere with an unlimited number of hexagons and just 12 pentagons at the joins. It's basically extending an icosohedron by tesselating the faces with hexagons.

Here is a sample:

« Last Edit: April 07, 2015, 10:08:10 pm by Reelya »
Logged

Magistrum

  • Bay Watcher
  • Skilled Fortresser
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7130 on: April 07, 2015, 10:07:27 pm »

I would refer to that as the "soccer ball sphere".
Logged
In a time before time, I had a name.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7131 on: April 07, 2015, 10:10:47 pm »

Yup. I linked it because it's actualy hard to find references to the model in procedural generation articles unless you know the specific term "Goldberg Polyhedron". The advantage of this system is that it scales up to an arbitrary number of cells.

It's more complex to implement than the cube-mapping but the advantage is that all the cells are the same shape, whereas cube mapping a sphere distorts angles from 90o to 120o where 3 meshes join up.
« Last Edit: April 07, 2015, 10:13:25 pm by Reelya »
Logged

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #7132 on: April 07, 2015, 10:50:25 pm »

Man, I keep thinking maybe I shouldn't have started with random terrain generation, but... it's kind of necessary before I move on. It's difficult to produce anything that doesn't occasionally look terrible.
Spoiler (click to show/hide)
Diamond-square usually produces something good, but very often you get small, messy spatters of mountain tiles. Changing the height cutoff doesn't help.
Spoiler (click to show/hide)
Simplex noise usually doesn't produce anything too irregular, but what it does produce is a little... simplistic, I guess? Not that the large, blobby elements will be all that visible when the map is zoomed in.
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

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7133 on: April 07, 2015, 11:15:30 pm »

The hard contrast between mountain and ordinary terrain might be your problem.

Maybe create some kind of intermediate "hills" terrain?
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7134 on: April 07, 2015, 11:35:48 pm »

^ Yup. If you create a 3D view you can get a better idea of what's happening. Since you have a hard cut-off point between green and white, a single point that goes over the threshold will look like an out of place mountain. It's no the algorithm causing the problem, it's the coloring system. you might find those are actually smooth hills which just happen to have one point clipping the high altitude.

Also with perlin or simplex noise, try increasing the octaves or changing the scaling parameters at each octave to get varying effects. One I'd I played around with a long time ago was using one noise function to provide per-point paramters for a second noise function. There's a lot of room to experiment in that area to get more differentiated effects.
« Last Edit: April 07, 2015, 11:38:32 pm by Reelya »
Logged

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #7135 on: April 08, 2015, 12:34:11 am »

Spoiler (click to show/hide)
Yeah, the problem was the gradient I was using. I made it a little more intense so you can see the contours of the mountains. I know the single-hex mountains are just slightly-too-tall hills, but it doesn't change the fact that they get produced. The only way I can think to get rid of them is a brute-force scan that finds small mountainous areas and flattens them. Transitional hills could work, if you mean making the mountains a smooth gradient rather than a sudden jump in color. But the purpose of the coloring is to show exactly which tiles are mountains, so it needs to be communicated visually regardless.

I've tried a few things with simplex noise, higher octaves and messing around with the scale help. I haven't tried using multiple noise functions together, however.
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

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7136 on: April 08, 2015, 01:23:55 am »

Mark every mountain hex that borders only one or two other mountain hexes.  Then flatten all the marked hexes down to just below the cutoff.

This will make sure that every surviving mountain has at least three hexes.
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7137 on: April 08, 2015, 02:02:41 am »

It's not physically possible to stop peaks being produced when you just cut through a heightmap at a certain altitude and call everything above it "mountains" and everything below it "plains" or something like that. You will get large parts which are above the threshold and you will also get parts when only a small portion is above the threshold. Changing the noise algorithm isn't really going to stop that. It's not really realistic to expect a noise algorithm not to exceed some arbitrary threshold in certain places yet exceed it strongly in others.

It's actually pretty realistic to have lone smaller peaks near areas of solid mountain. If you're not happy with that then you need to post-filter as suggested. Perhaps have an intermediate brown color, and phase smoothy from green(plains)->brown(hills), then have a hard border @ white mountains.



As you can see the area is mostly green, but with fractally-looking rocky parts. And there are indeed tiny split-off areas of rockiness leading up to the main rocky areas.
« Last Edit: April 09, 2015, 01:42:51 am by Reelya »
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #7138 on: April 08, 2015, 02:12:25 am »

If you composite two noise maps it might be easier to get a map that exceeds a threshold strongly in some areas and not so much in others!
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7139 on: April 08, 2015, 02:15:45 am »

Well that will make the mountain peaks taller, but it won't stop little bits peeking through.
Pages: 1 ... 474 475 [476] 477 478 ... 796