4
\$\begingroup\$

What I mean by resource distribution is the placement of items in the game. More specifically "minable" items in builder/resource gathering games like Factorio, Oxygen not included or/and RimWorld.

The games all place clumps of the same items around each other. For example in Factorio there will be fields of resources like coal, iron, copper, etc. which will spawn together in little clusters rather than there being single resource tiles being sprinkled around the map. See screenshot: enter image description here

This is a similar behaviour in Oxygen not included, similar resources are more likely to be next to each other but depending on the rarity they can also be found alone as a single block. In the game there are also zones which denote what resources can spawn which appear to be preset locations and shapes as they are the same each game (with the types mixed up), but resources themselves are position procedurally. I grabbed a screenshot online and highlighted some of the resource types to make the distribution more obvious. enter image description here

The ideal answer will show what methods would work well to reproduce "clustered resource distribution", with advantages and disadvantages of a given method. It will not necessarily have code examples but rather the rough steps/pseudocode that would have to be taken.

\$\endgroup\$
  • 1
    \$\begingroup\$ Probably some kind of noise \$\endgroup\$ – Bálint Sep 21 '17 at 17:10
  • \$\begingroup\$ "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." \$\endgroup\$ – Bálint Sep 21 '17 at 18:11
5
\$\begingroup\$

The same way you do all the other procedural generation, procedurally.

Typically this starts with "some kind of noise". Then you'll scale and filter the noise to extract data from it.

For example, you have a 2D array of pseudo-random noise with values ranging from 0 to 1. Map this 2D array to your world, likely via x,y coordinates. For all the values greater than .95 in your 2D array, add a copper node to the world at that point. The amount of copper in the node is higher the closer the value is to 1.

For example, in this image of a terrain, the developer has used a piecewise function to determine the elevation of the terrain. i.e.

if value > .9: elvation = 10, 
if .75 < value < .9: elevation = 8
etc.

enter image description here

For the resource example, only the highest terrain locations would be set as resource locations.

If you want your resource to be more common, instead of .95, choose .9 or some smaller number, thus increasing the area your resource covers.

Procedural maps like those in the games you reference are made up of many layers of noise. Each layer is a different scale with a different seed defining a different attribute. There will be layers for biomes, water, enemy placement, resources, etc. Some layers will reference other layers to ensure they're not violating placement rules (like resources on top of water).

All in all, it's a custom combination of rules and noise the create a complete map.

\$\endgroup\$
  • 2
    \$\begingroup\$ That screenshot looks like godus. But I can already tell, that it has more content than godus. \$\endgroup\$ – Bálint Sep 21 '17 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.