by halflings · 11y ago · 0 comments
Once you have access to random 2D data, it’s pretty straight forward to convert that noise into usable data. Simply set up thresholds for each tile type you want to support, eg:
* water if < 0.3
* grass if >= 0.3 and <= 0.6
* mountain if > 0.6
I recommend leaving the upper and lower cases open. If they are not left open, you may end up with holes in your map for unexpectedly high or low values. An alternative is to clamp or scale the noise values when you generate them.
If you expect to have more tile types, you should probably consider a categorical probability distribution (something like: water: 0.3, grass: 0.3, mountain: 0.4) and sample from it (instead of "hard-coding" it with the test you're referring to)