;; SUMMARY ;;;; Linked objects follow each other, endlessly. ;; COPYRIGHT & LICENSE ;;;; Copyright (C) 2004 James P. Steiner ;;;; Some Rights Reserved. ;;;; Creative Commons Attribution-NonCommercial-ShareAlike License v. 2.0. ;;;; Visit http://creativecommons.org/licenses/by-nc-sa/2.0/ for more information. ;; globals [ old-shape change-shape? frames ] Turtles-own [ link base-color direction ] to startup setup end To setup Ca Cct pop [ set link turtle ( (who + 1) mod pop) rt random 360 fd screen-edge-x set shape shape-choice set base-color (5 + who * 10) mod 140 ] display End To go ifelse frames >= frame-skip [ display no-display set frames 0 ] [ set frames frames + 1 ] ifelse shape-choice != old-shape [ set change-shape? true set old-shape shape-choice ] [ set change-shape? false ] if change-shape? [ 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-of turtle 0 != blue [ ask turtles [ set color blue ] ] ] [ if color-of turtle 0 != gray [ ask turtles [ set color base-color ] ] ] ask turtles [ ;; if my link is too close ifelse distance-nowrap link <= min-dist [ ; and I am not RIGHT on top if (xcor - xcor-of link) != 0 or (ycor - ycor-of link) != 0 [ set heading towards-nowrap link + avoid-heading jump step-size if double-correct [ set heading heading - avoid-heading ] ] ] [ ; if not to close, just turn-towards and step-forward set heading towards-nowrap link jump step-size ] ] End @#$#@#$#@ GRAPHICS-WINDOW 200 10 720 551 25 25 10.0 1 10 1 1 1 0 1 1 1 CC-WINDOW 5 565 729 660 Command Center 0 BUTTON 8 48 63 81 reset setup NIL 1 T OBSERVER T NIL BUTTON 123 49 178 82 NIL go T 1 T OBSERVER NIL NIL SLIDER 8 10 180 43 pop pop 10 1000 30 10 1 NIL SLIDER 8 121 181 154 min-dist min-dist 0.5 2 0.5 0.05 1 NIL BUTTON 123 85 178 118 scatter setxy random screen-size-x random screen-size-y NIL 1 T TURTLE T NIL SLIDER 9 191 182 224 avoid-heading avoid-heading 0 180 90 5 1 degrees SLIDER 8 156 181 189 step-size step-size 0 2 0.5 0.05 1 Units SWITCH 10 296 145 329 double-correct double-correct 0 1 -1000 CHOOSER 10 367 148 412 shape-choice shape-choice "default" "dotted-vector" "vector" "line" "circle" "circle-2" "box" "box-2" "ant" "chain" 1 SLIDER 9 226 181 259 size-factor size-factor 0.1 5 1.0 0.1 1 NIL SLIDER 11 414 190 447 frame-skip frame-skip 0 1001 0 1 1 frames 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\nset double-correct true NIL 1 T OBSERVER 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. =COPYRIGHT= Copyright © 2004 James P. Steiner. =LICENSE= Creative Commons Attribution-NonCommercial-ShareAlike License v. 2.0. Visit http://creativecommons.org/licenses/by-nc-sa/2.0/ for more information. @#$#@#$#@ 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 3.0.2 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@