Jump to content
  • Advertisement
Sign in to follow this  
SyncViews

Generating a random 2D ore deposit for a map

This topic is 646 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to generate an ore deposit centred approximately on a specific location with an approximate size and ore values (in the central area of the deposit).

The game is a 2D tile game and id be looking for the deposits to be roughly areas from 20x20 up to 50x50. Each ore tile has its own quantity (say up to 5000, or some patch specific "quality") for more variation and smoother transitions, but I want most of the falloff from around the fields peak to 0 to be around the edge.


void generateOrePatch(World world, int x, int y, int size, int quantity) { ? }

The problem I am having is how to effectively generate these ore tiles without some obvious geometric shape.

 

For example I tried multiplying some noise (e.g. Simplex) with a linear weight from the edge to the centre of my desired deposit. But of course the result is that while I get some variation within the deposit, the circle itself is obvious.

[attachment=35170:ore-values-simplex.png]

 

Ideally id like to generate with a lot of variety things like this one I did manually.

[attachment=35171:ore-values-paint.png]

Edited by SyncViews

Share this post


Link to post
Share on other sites
Advertisement

How about laying a few linear 'seams' with weighted vertices and then expanding out from those according to the weights?

Basically for each tile its ore content would be something like:

p = nearest point on nearest seam

d = distance to p

v = ore value of p (interpolated between seam vertices)

ore value for this tile = v/d^2

 

Just spitballing here.

Share this post


Link to post
Share on other sites
You can use the radial weight technique, only instead of multiplying it by a noise function, use the noise function to perturb(translate) the X and Y coordinates before calling the gradient function. This has the effect of actually distorting the shape of the radial gradient.

Share this post


Link to post
Share on other sites

scaled noise with a minimum cutfoff will give you what you want easily - IE just the densest part of the noise pattern. You might even superimpose a few splats to get the coverage you want. this can be combined with noise driven jitter in x and y as mentioned by JTippetts to mix it up even more.

Share this post


Link to post
Share on other sites

How about laying a few linear 'seams' with weighted vertices and then expanding out from those according to the weights?

Basically for each tile its ore content would be something like:

p = nearest point on nearest seam

d = distance to p

v = ore value of p (interpolated between seam vertices)

ore value for this tile = v/d^2

 

Just spitballing here.

I spent some time trying to implement this. Ran into a problem with borders between "seams" as you described it, which I partially solved by considering all lines (weighted sum), rather than just the nearest, but the lines still really stand out. Maybe I did fully understand.

[attachment=35243:gd-near.png]

[attachment=35242:gd-segments.png]

Using a sum of multiple lines instead to get a weight. But wondering how to hide the circle and line edge gradients.

[attachment=35244:gd-sum.png]

 

 

Still working on the perturb idea to see if I get anything good. But as I understand it, instead of doing something like "cellWeight = f(distanceToCenter(x,y)) * noise(x,y)" you are suggesting to do like "cellWeight = f(distanceToCenter(x + noise(x,y), y + noise(x,y))" where "f" is some simple function to map a weight to an ore value (including cutoffs for full-ore and no-ore cells).

Share this post


Link to post
Share on other sites

scaled noise with a minimum cutfoff will give you what you want easily

I dont understand how you get the noise peak at a desired location? I did consider using just noise for the entire thing (instead of a specified x,y,size) but had issues avoiding lots of "low yield" patches (I somewhat worked around it by a fairly expensive second pass that eliminated any patches with less than a certain total, or less than a certain cell average) but then had even more trouble making it interact well with other map features (e.g. in a flat desert plenty of ore spawned, but in mountain, water, etc. areas many areas are blocked)

Share this post


Link to post
Share on other sites
Ideally id like to generate with a lot of variety things like this one I did manually.

Alternative implementation from those discussed in this thread: make a bunch of random shapes just like that, rotate them at various angles. Probably no one will notice that they look similar to other ore patches. For additional variety combine two or more randomly-oriented random shapes with some max function and use that.

Edited by phil_t

Share this post


Link to post
Share on other sites

Yeah, that didn't work out as smoothly as I was thinking. How about this?

I was actually thinking about starting with connected lines, though, rather than scattered lines. Something like this:

8509a4e8e3.png

from which I was able to derive this

a0747a84f6.png

I did this in an imaging program, but the process is as follows:

  • Scatter vertices
  • Connect them into a minimal graph
  • All texels within N distance from any line are "selected"
  • "Feather" the edges of the selection by N/2: this is basically a large-scale anti-alias (can explain if needed)
  • Apply this as a mask to simplex noise (may want to try it multiplicatively as well)

The connectedness may not be that important though. From your scattered lines plot I got this:

92612573ce.png

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!