Jump to content

Diamond squares algorithm

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SmackBot (talk | contribs) at 17:45, 3 May 2007 (Date/fix the maintenance tags or gen fixes). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The diamond squares algorithm is used to create computer generated fractal landscapes. The idea was first introduced by Gavin S. P. Miller who described it as flawed. The algorithm starts with a 2D grid then randomly generates terrain height from four seed values arranged in a grid of points so that the entire plane is coveerd in squares. The algorithm is executed in two steps.

Steps

  1. Taking the four seed points that are arranged in a square, calculate a new vale where the diagonals would cross by averaging the values of the four points and adding a random amount. There should now be a pattern of diamonds across the network.
  1. Then do the same with the diagonals of the diamonds and you should have a pattern of squares again.
  1. After X ireterations take the values and translate them into height dimensions.

Sources

GameProgrammer.comGameProgrammer.com