;; 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   
@#$#@#$#@
GRAPHICS-WINDOW
9
10
141
163
30
30
2.0
1
10
1
1
1
0
0
0
1

CC-WINDOW
5
177
150
272
Command Center
0

@#$#@#$#@
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
@#$#@#$#@
default
true
0
Polygon -7500403 true true 150 5 40 250 150 205 260 250

circle
false
0
Circle -7500403 true true 0 0 300

cylinder
false
0
Circle -7500403 true true 0 0 300

dot
false
0
Circle -7500403 true true 90 90 120

face happy
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240

face neutral
false
0
Circle -7500403 true true 8 7 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Rectangle -16777216 true false 60 195 240 225

face sad
false
0
Circle -7500403 true true 8 8 285
Circle -16777216 true false 60 75 60
Circle -16777216 true false 180 75 60
Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183

line
true
0
Line -7500403 true 150 0 150 300

line half
true
0
Line -7500403 true 150 0 150 150

square
false
0
Rectangle -7500403 true true 30 30 270 270

x
false
0
Polygon -7500403 true true 270 75 225 30 30 225 75 270
Polygon -7500403 true true 30 75 75 30 270 225 225 270

@#$#@#$#@
NetLogo 3.0
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
