Created with
NetLogo version NetLogo 4.0.4

Running with NetLogoLite.jar version 404.

NetLogo Version: NetLogo 4.0.4

;;;; 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 ;; ;; globals [ max-d min-d ] turtles-own [ d ] to spawn-turtles ca let start read-from-string (substring start-position 0 1) set start item (start) [ "" "setxy 0 0" "set heading random-float 360 jump .8 * random-xcor" "setxy random-xcor random-ycor" "4" ] ifelse start = "4" [ ask n-of population patches with [ pxcor > min-pxcor + spread and pycor > min-pycor + spread ] [ sprout 1 [ setxy (pxcor - ( pxcor mod spread ) ) (pycor - ( pycor mod spread ) ) set heading random 360 set color 5 + 10 * who set shape "circle" set size 1 ] ] ] [ crt population [ run start set heading random 360 set color 5 + 10 * who set shape "circle" set size 1 ] ] set reaction spread * -.25 end to distribute-turtles let OK? true ask turtles [ set OK? (run-result avoid-method) and OK? ] tick if OK? [ stop ] end to-report back-away-any let crowd (turtles in-radius-nowrap spread) with [self != myself] let result true if any? crowd [ set crowd one-of crowd face crowd jump reaction set result false ] report result end to-report back-away-nearest let crowd (turtles in-radius-nowrap spread) with [self != myself] let result true if any? crowd [ set crowd min-one-of crowd [ distance myself ] face crowd jump reaction set result false ] report result end to-report back-away-any-from-center let crowd ((turtles in-radius-nowrap spread ) with [self != myself]) let cc count crowd let result true if any? crowd [ set crowd one-of crowd let h1 -1 if [xcor] of crowd != xcor or [ycor] of crowd != ycor [ set h1 towards crowd ] let h2 -1 if xcor != 0 or ycor != 0 [ set h2 towardsxy 0 0 ] if h1 = -1 [ set h1 h2 ] if h2 = -1 [ set h2 h1 ] ifelse h1 != -1 [ set heading mean-heading h1 h2 jump reaction ] [ set heading random-float 360 jump reaction ] set result false ] report result end to-report back-away-nearest-from-center let crowd ((turtles in-radius-nowrap spread ) with [self != myself]) let cc count crowd let result true if any? crowd [ set crowd min-one-of crowd [ distance myself ] let h1 -1 if [xcor] of crowd != xcor or [ycor] of crowd != ycor [ set h1 towards crowd ] let h2 -1 if xcor != 0 or ycor != 0 [ set h2 towardsxy 0 0 ] if h1 = -1 [ set h1 h2 ] if h2 = -1 [ set h2 h1 ] ifelse h1 != -1 [ set heading mean-heading h1 h2 jump reaction ] [ set heading random-float 360 jump reaction ] set result false ] report result end to-report mean-heading [ h1 h2 ] let diff .5 * subtract-headings h1 h2 report h2 + diff end to orbit ;; rotates turtles about the origin at a constant speed ;; (i.e. all turtle have the same speed within their orbital track ;; thus, all have a different angular speed) no-display ask turtles [ if pxcor != 0 or pycor != 0 [ if d = 0 [ set d -1 * distancexy 0 0 set heading towardsxy 0 0 ] setxy 0 0 lt 120 / (d * d ) * sin (360 * d / max-pxcor) ifelse can-move? d [ jump d ] [ die ] ] ] display end

distribute-turtles-avoid_2009

View or download the complete model file (to download: right-click, save-link-as):

-- Download distribute-turtles-avoid_2009 --