GeoGen Script reference
Example: Ouroboros

This script creates a ring of exactly identical islands.


The map is finite in both the horizontal and vertical directions.

Width: Finite,
Height: Finite,
Name: "Ouroboros",
Description: "Ring of exactly identical islands.",
Author: "Matěj Zábský",
NumberOfIslands: { Default: 5, Min: 2, Max: 10, Restriction: Integers }

First step is to create a template of a single island, which will be then copied several times to create the ring of islands. This template is centered at coordinate [0, 0], because it will have to be rotated later and rotation is always centered at [0, 0].

var noise = HeightMap.Noise(CreateNoiseLayers(32)).Multiply(0.5).Add(0.5).Multiply(0.8);
var templateMask = HeightMap.RadialGradient([0,0], Parameters.MapWidth * (0.14 - Parameters.NumberOfIslands * 0.01), 1, 0)
.Rescale(3, 1)
var template = HeightMap.RadialGradient([0,0], Parameters.MapWidth * (0.14 - Parameters.NumberOfIslands * 0.01), 1, -1)
.Rescale(3, 1)
.Add(noise, templateMask);

To create each island on the ring, the template is copied, rotated to be tangent to the circle, moved to its spot and then unified into the main map.

var main = HeightMap.Flat(-1);
var angleStep = 360 / Parameters.NumberOfIslands;
for(var angle = 0; angle < 360; angle += angleStep)
var offset = [
Parameters.MapWidth / 2 + Cos(DegToRad(angle)) * Parameters.MapWidth * 0.35,
Parameters.MapHeight / 2 + Sin(DegToRad(angle)) * Parameters.MapHeight * 0.35];
var clone = HeightMap.Clone(template)
.Rotate(DegToRad(angle + 90))

The last step is to fill in the remaining flat areas with some generic noise. To do this, a mask that is an inverse of the map itself is used (so more of the noise is used where the heights in the map are the least). The same noise is used as the one which was used for the template. There is no reason not to.

var mask = HeightMap.Clone(main)
.ClampHeights(-1, -0.05)
main.Add(noise.Multiply(0.5).Add(0.5), mask);
yield main;

Full code