Public Group

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.

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 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.

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 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 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 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 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 on other sites

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

from which I was able to derive this

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:

1. 1
2. 2
Rutin
20
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633737
• Total Posts
3013614
×