# Turtle Distribution Demo

Model was written in NetLogo 6.1.1
•
Viewed 121 times
•
Downloaded 18 times
•
Run 0 times

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## Comments and Questions

Please start the discussion about this model!
(You'll first need to log in.)

Click to Run Model

to setup-turtle set color 5 + who * 10 set size 1 set shape "circle" end to distribute-turtles-arc clear-all let radius 0 let circumference 0 let arc 360 let angle 0 let arclength spread let segments 1 let counter 0 let max-radius max-pxcor * sqrt 2 ;; make one turtle. try to place it. ;; if it can be placed, kill it. ;; try the next place ;; (until the current ring is completely out of the world) while [ counter < population and radius < max-radius ] [ crt 1 [ set heading angle ifelse can-move? radius [ setup-turtle jump radius set counter counter + 1 ] [ die ] ] set angle angle + arc if angle >= 360 - arc * .5 [ ;; ring complete, calculate parameters of next ring set angle angle - 360 set radius radius + spread set circumference pi * radius * 2 set segments floor (circumference / arclength) set arc 360 / segments ] ] end to distribute-turtles-grid clear-all ask n-of population (patches with [ pxcor mod spread = 0 and pycor mod spread = 0 ]) [ sprout 1 [ setup-turtle ] ] end to distribute-turtles-spread clear-all ask n-of population patches [ sprout 1 [ setup-turtle ] ] let settled? false let start timer let timeout start + 5 ;; max 5 seconds to settle while [ (not settled?) and (timer < timeout) ] [ set settled? true ask turtles [ let too-close other (turtles in-radius spread) if any? too-close [ face one-of too-close ifelse can-move? -.1 [ jump -.1 ] [ setxy random-pxcor random-pycor ] ask too-close [ face myself ifelse can-move? -.1 [ jump -.1 ] [ setxy random-pxcor random-pycor ] ] set settled? false ] ] ] let settled precision (timer - start) 4 clear-output output-print (word "Settled in " settled " seconds") ;; un-crowd turtles ask turtles [ if any? other (turtles in-radius spread) [ die ] ] end to orbit every ( 1 / 30 ) [ ask turtles [ if pxcor != 0 or pycor != 0 [ let d distancexy 0 0 let h heading setxy 0 0 set heading heading + 360 / size / d / 30 ifelse can-move? d [ jump d ] [ die ] ] ] ] end ;; for modeling commons automatic thumbnail maker to setup distribute-turtles-spread end to go end

There are 2 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Turtle Distribution Demo.png | preview | Preview for 'Turtle Distribution Demo' | over 2 years ago, by James Steiner | Download |

This model does not have any ancestors.

This model does not have any descendants.