GeoGen Script reference
Example: Ouroboros

This script creates a ring of exactly identical islands.

examples_ouroboros.png

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

metadata
{
Width: Finite,
Height: Finite,
Name: "Ouroboros",
Description: "Ring of exactly identical islands.",
Author: "Matěj Zábský",
Parameters:
{
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)
.Blur(50);
var template = HeightMap.RadialGradient([0,0], Parameters.MapWidth * (0.14 - Parameters.NumberOfIslands * 0.01), 1, -1)
.Multiply(0.4)
.Rescale(3, 1)
.Blur(20)
.Add(noise, templateMask);
examples_ouroboros_template.png

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))
.Move(offset);
main.Unify(clone);
}
examples_ouroboros_copies.png

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)
.Invert()
.Add(-0.05)
.Blur(10);
main.Add(noise.Multiply(0.5).Add(0.5), mask);
yield main;
examples_ouroboros_mask.png

Full code