layout-circle
is a primitive that moves a set of turtles into an evenly spaced circle of a given radius. For example:
create-turtles 100 [
set shape "person"
]
layout-circle turtles 10
Things to keep in mind when using layout-circle
:
layout-circle
is an observer-only primitive, so you cannot use it within an ask
statement.layout-circle tables 3
.The model example below demonstrates how layout-circle
works. It has two setup buttons: one to create an empty model and another to create a model with 10 houses at random places. When the go button is clicked, we create a new house at each tick if there are less than 10 houses (i.e. if we used the setup-empty button). Then, we use layout-turtle
to organize our neighborhood. This model also includes a variable radius and increments it at each tick to show how layout-turtle
works for different radius values.
xxxxxxxxxx
globals [ radius ]
to setup-empty
clear-all
set radius 2
reset-ticks
end
to setup-random
setup-empty
make-houses 10
end
to go
if count turtles < 10 [
make-houses 1
]
layout-circle turtles radius
set radius radius + 0.1
if radius > 5 [ set radius 2 ]
tick
end
to make-houses[n]
create-turtles n [
set shape "house"
setxy random-xcor random-ycor
]
end
Once you mastered the layout-circle
primitive, don't stop there. Check out the resources below to improve your NetLogo skills.
layout-circle
primitive:create-links-with
Creates links with every agent in an agentset.
reset-ticks
Sets the tick counter to 0.
link-neighbors
Reports all agents connected to a turtle with links.