Fractal way of map generation by using diamond-square algorithm

Diamond-square algorithm is a simple way to generate maps by using fractal approach. The idea is to generate recursively a point based on the values of its neighbors and an additional fluctuation.

The main disadvantage is that landscapes aren't realistic and there exist visible edges created during recursive slicing of the terrain during recursive computing

Below you may see how the diamond-square algorithm works. Availability to change perspective is not part of the algorithm, but I've added it to make the visualisation more user-friendly.

up
left create new right
down

To check exactly, how the scripts are working please take a look on the source code of this page.

Above scripts were created a couple of years ago, they may not be aligned with the modern way of doing things in JavaScript. The code can be hard to read, I've written it when I was a student, back in those days I've been in love in short variable names and lack of comments.

4 comments:

  1. Cantor set should go from the middle of the image till infinitivy down.

    ReplyDelete