tiny-swirl


Information

Created with NetLogo version NetLogo 3.0
Running with NetLogoLite.jar version 302.


INFORMATION


-------
A tiny, self-starting source-map demo. A source map is a grid transform where each cell of the grid points to some other cell, the source. The location of the source can be handmade, or derived from a formula or algorithm. The cell takes its next value from the source.

COPYRIGHT


-----
Tiny-swirl Copyright (C) 2005 James P. Steiner

Procedures

NetLogo Version: NetLogo 3.0

;; SUMMARY
;;;;  A tiny source-map demostration.
;; COPYRIGHT & LICENSE
;;;; Copyright (C) 2005 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.
;; APPLET DIMENSIONS (width x height)
;;;; 149 x 161
;;
globals
[ click?
  running?
]


patches-own
[ my-source
  value
  new-value
]

to startup
   setup
   loop
   [ go ]
end

to setup
   ca
   set running? true
   set click? false
   ask patches
   [ let angle ( 2 * distancexy 0 0 / screen-edge-x * 360 + .5 * smart-towardsxy 0 0)
     set value random-float 2 - 1
     set pcolor (value + 1 ) * 35
     set my-source patch-at (1.9 * sin (angle)) ( 1.9 * cos (angle))
   ]
   ask patches with [ abs pxcor = screen-edge-x or abs pycor = screen-edge-y ]
     [ set my-source patch 0 0 ]
   
end

to go
   if running? = true
   [ 
     no-display
     ; diffuse value .5 
     ask patches
     [ set new-value value-of my-source ]
     diffuse value .1
     ask patches
     [ set value value * .5 + .5 * new-value ; ( value + new-value ) * .5
       set pcolor (value + 1 ) * 75
     ]
     if random 1000 < 20
     [ let rvalue random 3 - 1
       ask patches with [ abs pxcor = screen-edge-x or abs pycor = screen-edge-y ]
       [ set value rvalue
         set pcolor (value + 1 ) * 75
       ]
     ]
     display
   ]
   go-mouse-effects
   wait 1 / 15
end

to go-mouse-effects
   ifelse mouse-down?
   [ if click? != true [ set click? true ] ]
   [ if click? = true  [ set running? not running? set click? false ] ]
end

to-report smart-towardsxy [ a b ]
   ifelse a != 0 or b != 0
   [ report towardsxy a b ]
   [ report 0 ]
end   

                    


Download Link

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