;;;; SUMMARY
;; Distributing a number of evenly spread out turtles
;;;; Copyright & License
;; Copyright (C) 2006 James P. Steiner
;; You are granted a CC 2.5 by-nc-sa license to this model
;;
;;
to distribute-turtles
   ca
   let side ceiling sqrt population
   ask patches with [ pxcor - min-pxcor < side and pycor - min-pycor < side ]
   [ sprout 1
     [ set color 5 + who * 10 ]
   ]
   
   ask turtles
   [ let newx pxcor + ((pxcor - min-pxcor) * .8660 * (spread - 1)) 
     let newy pycor + ((pycor - min-pycor) * (spread - 1) + spread * (ifelse-value ( (pxcor ) mod 2 = 0) [ 0 ] [ .5 ]))
     ifelse newx > max-pxcor or newy > max-pycor
     [ die ]
     [ setxy newx newy 
       set size spread
       set heading 0
       set shape use-shape
     ]
   ]

   if (count turtles) > population
   [ ask n-of (count turtles - population) turtles
     [ die ]
   ]

end
   
   
to orbit
no-display
ask turtles
[ if pxcor != 0 or pycor != 0
  [ let d distancexy 0 0
    facexy 0 0
    rt 180
    let h heading
    setxy 0 0
    set heading heading + 5 / d
    ifelse can-move? d
    [ jump d ]
    [ die ]
  ]
]  
display
end      
   
   
   
@#$#@#$#@
GRAPHICS-WINDOW
190
10
503
344
50
50
3.0
1
10
1
1
1
0
0
0
1
-50
50
-50
50

CC-WINDOW
5
358
512
453
Command Center
0

SLIDER
10
10
182
43
spread
spread
1
10
7
1
1
NIL

SLIDER
10
46
182
79
population
population
100
10500
200
100
1
NIL

BUTTON
11
135
135
168
NIL
distribute-turtles
NIL
1
T
OBSERVER
T
NIL

MONITOR
11
173
94
222
NIL
count turtles
3
1

BUTTON
10
231
77
264
orbit
orbit
T
1
T
OBSERVER
NIL
NIL

BUTTON
90
232
156
265
pretty
set color scale-color blue heading 0 360\nset size spread\nset shape "circle"
NIL
1
T
TURTLE
T
NIL

CHOOSER
10
84
148
129
use-shape
use-shape
"circle" "hex"
1

@#$#@#$#@
@#$#@#$#@
default
true
0
Polygon -7500403 true true 150 5 40 250 150 205 260 250

link
true
0
Line -7500403 true 150 0 150 300

link direction
true
0
Line -7500403 true 150 150 30 225
Line -7500403 true 150 150 270 225

circle
false
0
Circle -7500403 true true 0 0 300

hex
true
0
Polygon -7500403 true true 0 150 75 15 225 15 300 150 225 285 75 285

tree
false
0
Circle -7500403 true true 118 3 94
Rectangle -6459832 true false 120 195 180 300
Circle -7500403 true true 65 21 108
Circle -7500403 true true 116 41 127
Circle -7500403 true true 45 90 120
Circle -7500403 true true 104 74 152

@#$#@#$#@
NetLogo 3.1.1
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
