

As secondary effect, this new turtle will connect with the extremes of the segment. The midpoint of a link will return a turtle in the middle of the segment. Report that returns a random between -x and x In every iteratio the displacement is reduced according to roghness factor to iterĪsk (midpoint ?) Īsk ? ] Remove the original link after division

By convenience, we define an auxiliary report to return a random number in a symmetrical interval. Note that we have to use a foreach iteration, and not only a ask links, because the creation of new turtles can't be done inside a link context. The iteration procedure will pass through all the links/segments, calculate their mid points and displace them. For a better visualization, we hide the turtles at the end Procedure to create the final curve: only a single loop Setxy (2 * who - 1) * max-pxcor random-ycor / 2Ĭreate-links-with other turtles Create the 2 first points (in the borders), and a link (segment) Create the initial conditions for the algorithm In NetLogo we can easily do this by using links and iterating on them in every step: globals [ĭisp Displacement value for the mid points

It is also known as a Plasma Algorithm, a set of algorithms that produce liquid effects when changing the colors in a cyclic over a prefixed palette of colors (probably, the first algorithms of this type were created by demo coders in the 90's by using some specific features of the display hardware from that time). From a computational point of view this algorithm is very inexpensive when compared to other terrain generation algorithms, and it provides a very impressive results. The mid point displacement algorithm is a subdivision algorithm that generates a terrain iteratively, in each iteration the level of detail increases.
