Reputation: 103
I wanted to initialise my world with turtles that would theoretically occupy x% of the total surface area or the size of the world. How do I know what is the exact size of each turtle? I know the world size can be calculated by:
world-width
world-height
My turtles are triangular in size and currently a size 4 and as per patch size 5 and dimensions of the world set to -80 80 -80 80, this size is perfect and I would like to keep it at size 4.
How do I calculate what number of turtles would occupy 1%, 5%, 10%, 20% and 40% of the entire surface area?
Upvotes: 1
Views: 74
Reputation: 2780
You are on the right track with world-width
and world-size
. Those give you the size of the world, based on the number of patches.
If you want to make a turtle to have half the surface area, you just need to update it's size
variable, which is also measured in patches. So a turtle with size
of 1 is exactly as tall and wide as a single patch.
to make-half-size-square
clear-all
; assumes we want a square shape, just use `sqrt` on the total world surface area
let half-surface-size sqrt (world-width * world-height / 2)
show half-surface-size
crt 1 [
set shape "square"
set size half-surface-size
]
end
to make-half-size-circle
clear-all
; assumes we want a circle shape
let half-surface-size 2 * sqrt ((world-width * world-height / 2) / pi)
show half-surface-size
crt 1 [
set shape "circle"
set size half-surface-size
]
end
A couple extra bits of info, though:
size
only controls the visual size of the turtle in the world view. It still only lives on a single patch. If you want to get all turtles/patches "under" the turtle shape you'll need to use in-radius
(for a circle) or do a bounding-box check using the turtle's size
(for a square).square
shape that comes with NetLogo doesn't quite have its edges all the way at the end, but the circle
does.Upvotes: 2