Beginners Interactive NetLogo Dictionary (BIND)
Farsi / Persian
NetLogo Models Library:
This code example shows how to use the basic neighborhood primitives. These include
neighbors: reports the patches surrounding a patch or turtle both patches that share a side and those that share a corner. If the world is a torus every patch will have eight neighbors, if wrapping is not allowed in either direction the edge patches will have fewer neighbors.
neighbors4: reports the same patches, excluding the ones at the corners. On a torus there will always be four neighbors.
<agentset> in-radius <number>: reports those agents in agentset whose distance from the caller is less than or equal to n.
<agentset> at-points <list>: reports those agents in agentset at the given points relative to the caller, where
list is a list of two-number lists.
Although in this example, we only change the color of the reported patches, you can of course do more complicated operations, including assigning that agentset to a variable. This is particularly useful in cellular automata models.
Moore & Von Neumann Example shows how to use square (Moore) or diamond (Von Neumann) shaped neighborhoods of any size.
neighbors4 in the sample models see Shepherds, Altruism, GenDrift P local, Ising, Crystallization models, CA models, Fire, Rumor Mill, Segregation, and Voting.
in-radius in the sample models see Fireflies, Flocking, and Simple Kinetics 3.
at-points in the sample models see the Crystallization models, and Wave Machine.