;; SUMMARY globals [ old-shape change-shape? frames ] Turtles-own [ next base-color direction ] to startup setup end To setup Ca ;; Assign each turtle to follow the next-highest turtle crt pop [ set next turtle ( (who + 1) mod pop) rt random 360 jump max-pxcor set shape shape-choice ;; rainbow colors set base-color hsb (255 * who / (pop + 1)) 255 255 set color base-color ] tick End To go if not any? turtles [ setup ] if [ shape ] of turtle 0 != shape-choice [ ask turtles [ set shape shape-choice ] ] ifelse scale-with-min-dist? [ let new-size min-dist * size-factor ask turtles with [ size != new-size ] [ set size new-size ] ] [ let new-size size-factor ask turtles with [ size != new-size ] [ set size new-size ] ] ifelse unicolor? [ if [color != blue ] of turtle 0 [ ask turtles [ set color blue ] ] ] [ if [color != base-color] of turtle 0 [ ask turtles [ set color base-color ] ] ] ask turtles [ ;; if my next is too close ifelse distance-nowrap next <= min-dist [ ;; turn towards it, and away a little bit face-nowrap next rt avoid-heading ;; jump jump step-size ] [ ; if not to close, just turn-towards and step-forward face-nowrap next jump step-size ] ] tick End @#$#@#$#@ GRAPHICS-WINDOW 200 10 720 551 25 25 10.0 1 10 1 1 1 0 1 1 1 -25 25 -25 25 1 1 1 ticks CC-WINDOW 5 565 729 660 Command Center 0 BUTTON 8 48 63 81 reset setup NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 123 49 178 82 NIL go T 1 T OBSERVER NIL NIL NIL NIL SLIDER 8 10 180 43 pop pop 10 1000 100 10 1 NIL HORIZONTAL SLIDER 8 121 181 154 min-dist min-dist 0.5 2 0.5 0.05 1 NIL HORIZONTAL BUTTON 123 85 178 118 scatter setxy random world-width random world-height NIL 1 T TURTLE NIL NIL NIL NIL SLIDER 9 191 182 224 avoid-heading avoid-heading 0 180 90 5 1 degrees HORIZONTAL SLIDER 8 156 181 189 step-size step-size 0 2 0.5 0.05 1 Units HORIZONTAL CHOOSER 10 367 148 412 shape-choice shape-choice "default" "dotted-vector" "vector" "line" "circle" "circle-2" "box" "box-2" "ant" "chain" 3 SLIDER 9 226 181 259 size-factor size-factor 0.1 5 1 0.1 1 NIL HORIZONTAL SWITCH 10 261 182 294 scale-with-min-dist? scale-with-min-dist? 1 1 -1000 SWITCH 10 331 116 364 unicolor? unicolor? 1 1 -1000 BUTTON 9 84 64 117 default set min-dist .50\nset step-size .50\nset avoid-heading 90\nset size-factor 1.0\nset scale-with-min-dist? false NIL 1 T OBSERVER NIL NIL NIL NIL @#$#@#$#@ ==SUMMARY== Linked chains follow each other. ==WHAT IS IT?== A simple model. A chain of linked turtles. They follow each other. That is, each link as a "leader". Each link steps toward its leader, until it is some minimum distance, if the leader is too close, the link steps away at a preset angle. Use the sliders and switches to vary the rules that are used. Some interesting effects emerge, especially with many links. ===THE CONTROLS=== |pop| - how many links in the chain. can not be changed during GO. |min-dist| - the closest that links want to get when 'scale-with-min-dist' is on, size-factor is multiplied by this value. |step-size| - how far a link moves each step smaller values make for smoother movement, but experiement with larger values too: interesting effects emerge. |avoid-heading| - the angle added to the current heading when the lead is too close |size-factor| - the base size of the links. |scale-with-min-dist| - when on, the size is scaled by min-dist. for links that seem to be connected, turn this on, then set size-factor to 2. |double-correct| - after turning away and stepping forward or backward, turn back by the same amount |shape-choice| - choose the shape to use for the chain. different shapes reveal different information about the chain: * lines show the way angles change * circle hides the chaning angles, but lets one focus on the chain as a whole. * dotted-vector accentuates the curvyness of a shape. |frame-skip| - model skips displaying this many frames. speeds things up, can hide complexity for rapidly evolving shapes, can use to freeze-frame repeating shapes, and determine the cycles ==THINGS TO LOOK FOR== when a link wraps across an edge, the result is usually that the follower turns and crosses the screen to get back to it. this can keep a chain system unstable. * some chain systems will stabilize given enough room and time * some will shrink/expand into a circle * some never calm down * some seem stable for awhile (especially larger chains) then suddenly shift. * note that often the overall *shape* is fairly stable, even though the individual * members are racing around and around the perimiter. ==NETLOGO FEATURES== * Well chosen shapes can expose information. * Using nodisplay and display to control screen-redrawing * Storing turtles in a turtle variable creates linked turtles * turtle scaling strongly affects execution speed. === XML Tags === Linked objects follow each other, endlessly. Copyright (C) 2004,2009 James P. Steiner @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 ant true 0 Polygon -7500403 true true 136 61 129 46 144 30 119 45 124 60 114 82 97 37 132 10 93 36 111 84 127 105 172 105 189 84 208 35 171 11 202 35 204 37 186 82 177 60 180 44 159 32 170 44 165 60 Polygon -7500403 true true 150 95 135 103 139 117 125 149 137 180 135 196 150 204 166 195 161 180 174 150 158 116 164 102 Polygon -7500403 true true 149 186 128 197 114 232 134 270 149 282 166 270 185 232 171 195 149 186 Polygon -7500403 true true 225 66 230 107 159 122 161 127 234 111 236 106 Polygon -7500403 true true 78 58 99 116 139 123 137 128 95 119 Polygon -7500403 true true 48 103 90 147 129 147 130 151 86 151 Polygon -7500403 true true 65 224 92 171 134 160 135 164 95 175 Polygon -7500403 true true 235 222 210 170 163 162 161 166 208 174 Polygon -7500403 true true 249 107 211 147 168 147 168 150 213 150 box true 0 Polygon -7500403 true true 45 255 255 255 255 45 45 45 box-2 true 0 Rectangle -7500403 true true 75 0 225 150 chain true 1 Circle -2674135 false true 104 74 92 Circle -2674135 false true 106 -14 88 circle false 0 Circle -7500403 true true 35 35 230 circle-2 true 0 Circle -7500403 true true 75 0 150 dotted-vector true 1 Line -2674135 true 150 150 150 -3 Line -2674135 true 148 0 136 30 Line -2674135 true 150 0 165 29 Circle -2674135 true true 136 136 28 Circle -2674135 true true 136 285 28 line true 1 Line -2674135 true 150 150 150 -3 vector true 1 Line -2674135 true 150 150 150 -3 Line -2674135 true 148 0 136 30 Line -2674135 true 150 0 165 29 Circle -2674135 true true 136 136 28 @#$#@#$#@ NetLogo 4.0.4 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@