home

author: niplav, created: 2020-11-20, modified: 2024-01-26, language: english, status: notes, importance: 4, confidence: highly likely

The Diamond-Square algorithm is a terrain-generation algorithm for two dimensions (producing a three-dimensional terrain). I generalize the algorithm to any positive number of dimensions, and analyze the resulting algorithm.

Generalizing the Diamond-Square Algorithm to n Dimensions

Libre de la metáfora y del mito
labra un arduo cristal: el infinito
mapa de Aquel que es todas Sus estrellas.

Jorge Luis Borges, “Spinoza”, 1964

Introduction

I learned of the diamond-square algorithm by reading through the archives of Chris Wellon's blog, specifically his post on noise fractals and terrain generation. The algorithm is a fairly simple and old one (dating back to the 80s), but not being interested in graphics or game programming, I shelved it as a curiosity.

However, a while later I needed a way to generate high-dimensional landscapes for a simulation, and remembered the algorithm, I felt like I could contribute something here by generalizing the algorithm to produce landscapes in an arbitrary number of dimensions, and that this would be a fun challenge to sharpen my (then fairly weak) Python and numpy skills.

Description

The original (2-dimensional) diamond-square algorithm (in its simplest form) starts with a $2^n+1 \times 2^n+1$ array of numbers.

Code here.

Square

Diamond

Analysis

Results

One Dimension

Space generated by the algorithm in one dimension

Two Dimensions

Space generated by the algorithm in two dimensions

Three Dimensions

Space generated by the algorithm in three dimensions