globals [ the-planet g cd? ; ticks all-stable? stable-ticks ] breed [ planets a_planet ] breed [ objects an_object ] planets-own [ mass vx vy radius ] objects-own [ mass ax ay vx vy xx yy fuel ph dlist stable-orbit? base-color ] to startup setup end to setup ca set g 6.67259e-11 create-planets 1 [ set the-planet self home set shape "planet" set radius 6.378 ;; KKM set size 20 set mass 5.9742e21 ;; tonnes set vx random-float .1 set vy random-float .1 ] create-objects 10 [ make-ship pd ] end to go if move-planet? [ move-planet ] set cd? false move-objects if cd? [ cd ] ;if ticks <= 0 [ tick-advance frame-skip] ;tick ;ifelse all-stable? [ set stable-ticks stable-ticks + 1 ] ;[ set stable-ticks 0 ] ;if stop-when-stable? and stable-ticks >= 360 ;[ tick stop ] tick end to move-planet ask planets [ let mx mean [ xx ] of objects - xcor let my mean [ yy ] of objects - ycor set heading atan mx my set vx vx * .99 + dx * .0001 set vy vy * .99 + dy * .0001 set xcor xcor + vx set ycor ycor + vy ] end to move-objects set all-stable? true ask objects [ ;if d < 10 * s [ escape ] let f [ f-list ] of planets let fx mean map [ first ? ] f let fy mean map [ last ? ] f set ax fx set ay fy set vx vx + ax set vy vy + ay set xx xx + vx set yy yy + vy let d distance the-planet let r [radius] of the-planet if d <= r [ make-ship ] ifelse visible-x xx and visible-y yy [ set xcor xx set ycor yy if hidden? [ show-turtle ] ] [ if not hidden? [ hide-turtle set vx 0 set vy 0 ] ] if vx != 0 or vy != 0 [ set heading atan vx vy ifelse abs ( subtract-headings ph floor heading) > .0001 [ set ph floor heading let rd item ph dlist let nd 10 * floor (d * .1) let new-so? (rd = nd) ifelse new-so? [ ] [ set dlist replace-item ph dlist nd set all-stable? false ] if stable-orbit? != new-so? [ set stable-orbit? new-so? ifelse stable-orbit? [ if shape != "sat-stable" [ set shape "sat-stable" ] ] [ if shape != "sat" [ set shape "sat" ] ] ] ] [ let tph towards the-planet if abs (subtract-headings heading tph) < 5 [ set shape "sat-collide" ] ] ] ] end to-report f-list let scale .00000000000002 let d distance myself let t towards myself let f -1 * ( (g * (mass * scale) * ([mass] of myself * scale)) / ( d * d ) ) let fx f * sin t let fy f * cos t report list fx fy end to-report visible-x [ x ] report (x > min-pxcor and x < max-pxcor) end to-report visible-y [ y ] report (y > min-pycor and y < max-pycor) end to make-ship let pm pen-mode pu set dlist n-values 360 [ 0 ] set ph 0 set shape "sat" set size 20 set mass 1.0e18 ;; tonnes let r (((random 2 )* 2 )- 1) * ( max-pxcor * .5 + random-float .5 * max-pxcor ) set heading random-float 360 jump r set heading random-float 360 set ph heading set vx dx set vy dy set vx vx * 1 set vy vy * 1 set xx xcor set yy ycor set pen-mode pm set base-color color set cd? true end to escape let h atan vx vy let t towards the-planet let eh subtract-headings h t ifelse eh > 0 [ set eh 135 ] [set eh -135] set eh t + eh set vx vx + .0001 * sin eh set vy vy + .0001 * cos eh end @#$#@#$#@ GRAPHICS-WINDOW 155 10 666 542 250 250 1.0 1 10 1 1 1 0 0 0 1 -250 250 -250 250 1 1 1 ticks CC-WINDOW 5 556 675 651 Command Center 0 BUTTON 10 145 65 178 reset setup NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 10 15 65 48 NIL go T 1 T OBSERVER NIL NIL NIL NIL BUTTON 10 55 75 88 toggle-pen ifelse any? turtles with [pen-mode = \"up\" ] [ask turtles [ pd ] ] [ ask turtles [ pu ] cd ] NIL 1 T OBSERVER NIL NIL NIL NIL SWITCH 10 100 126 133 move-planet? move-planet? 0 1 -1000 @#$#@#$#@ WHAT IS IT? ----------- A model that draws massiv objects orbiting around a more massive object. The model uses simple orbital physics to calcualte the paths of the orbiting objects. The positions of the objects are stored in a table. When the objects current position is similar to a recorded position, the object's orbit is marked "stable" -- In other words, the object is not going to crash into the planet, or shoot off into distance space. When "move-planet" is on, the planet is tugged by the orbiting bodies, making it more difficult to obtain stable orbits. @#$#@#$#@ default true 3 Polygon -13840069 true false 75 255 30 225 45 225 45 210 60 210 60 195 90 240 Polygon -13840069 true false 135 60 120 30 135 0 165 0 180 30 165 60 Polygon -6459832 true true 120 60 180 60 210 75 225 105 225 210 210 240 180 255 120 255 90 240 75 210 75 120 90 75 120 60 120 90 180 90 105 210 120 225 195 105 195 210 180 225 120 225 105 210 105 105 120 90 Polygon -13840069 true false 135 255 150 270 135 300 165 270 165 255 Polygon -13840069 true false 225 255 270 225 255 225 255 210 240 210 240 195 210 240 Polygon -13840069 true false 225 90 270 60 255 60 255 45 240 45 240 30 210 75 Polygon -13840069 true false 75 90 30 60 45 60 45 45 60 45 60 30 90 75 Polygon -10899396 true false 105 210 105 105 120 90 180 90 Polygon -10899396 true false 120 225 195 105 195 210 180 225 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 planet false 0 Circle -13345367 true false 0 0 300 Polygon -10899396 true false 90 60 45 90 30 135 30 165 15 150 15 180 45 195 45 240 75 270 60 270 30 240 0 180 0 150 15 90 30 60 60 30 60 45 Polygon -10899396 true false 105 105 120 120 135 105 150 105 150 135 165 105 180 135 150 150 105 150 90 165 90 180 105 195 120 210 135 255 150 270 165 240 165 165 180 150 225 180 240 135 285 150 285 105 255 45 225 30 180 60 165 30 135 75 120 75 120 90 Polygon -1 true false 216 14 177 16 165 6 159 16 139 19 124 15 82 16 122 1 178 1 Polygon -1 true false 84 286 123 284 135 294 141 284 161 281 176 285 218 284 178 299 122 299 sat false 0 Circle -7500403 true true 30 30 240 sat-collide true 0 Polygon -2674135 true false 0 135 60 135 30 90 75 75 75 30 105 60 150 0 150 45 225 30 210 75 255 75 240 120 285 120 255 165 285 195 240 210 270 255 225 240 195 285 195 390 165 330 150 480 135 330 105 375 105 270 60 315 75 255 75 225 30 255 60 195 0 210 45 165 Polygon -955883 true false 120 270 120 210 105 240 105 180 75 195 105 150 45 165 90 135 60 90 120 105 90 60 135 90 135 45 165 105 180 45 180 90 225 75 195 135 255 120 195 165 225 210 180 210 180 255 165 225 165 345 135 255 Polygon -1184463 true false 135 135 135 105 150 135 180 105 165 135 195 150 165 165 195 195 165 180 150 255 135 180 120 195 135 165 105 135 sat-stable false 0 Circle -7500403 true true 0 0 300 Polygon -16777216 true false 45 180 75 135 150 195 255 45 165 270 @#$#@#$#@ 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 @#$#@#$#@