tayacost.blogg.se

Netlogo shapes
Netlogo shapes








netlogo shapes
  1. #NETLOGO SHAPES CODE#
  2. #NETLOGO SHAPES DOWNLOAD#

#NETLOGO SHAPES CODE#

The code to perform this algorithm is given now. Of course, we will keep this value between bounded values, for example between 0 and 3. In this way, with only 8 iterations we will obtain a terrain with \(257\times 257\) heights generated on a grid of patches (hence, be careful with the number of iterations or NetLogo will complain about the memory).Īlso, we will have a roughness parameter that determines the look of the final terrain, from extremelly rough (0 value) to absolutely smooth (\(\infty\) value). Instead of using a iterative segmentation of a simple square to get a grid of points, we prefix the points of the grid and fill them with the same method (note that, the 2D coordinates of the points are prefixed in any case). In order to make easier this iterative process, we will consider that the size of the world will be of the form \((2^s + 1) \times (2^s + 1)\), where \(s\) will be the number of iterations. In this case we will need to split the iteration in two stages, in the first one we need to calculate the central point of every square ( diammond phase), and later, we use this central point and the corners to calculate the midle points again ( square phase): The same idea works on building 2D terrains.

#NETLOGO SHAPES DOWNLOAD#

Here you can try the model (or download it, if you want): Create one turtle in the middle point of e1 - e2 and report itĬreate-links-with of s [ link it to e1

netlogo shapes

Let y 0 ycor of midpoint Fill this values from the link, and remove it 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 Repeat from step 1 until we reach the desired number of points / segment size.Calculate the middle point of the segment.In this simple case we start with an initial segment an then apply the next algorithm:

netlogo shapes

The general process is simple, and we will start with a 1D version to exemplfy the algorithm. 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.










Netlogo shapes