Java StarLogo
2.0
english
`turtle`
to setup
setxy -1 + random 3 -1 + random 3
place
end

to go
ifelse free                                   ; if a turtle is moving freely (see below), it
 [fd 1]                                       ;   takes a step forward; otherwise, it calls
 [place]                                      ;   procedure place to color the patch and relocate
end


to free
rt random wiggle                                     ; turtle wiggles randomly to a maximum angle of
lt random wiggle                                     ;   wiggle (a slider variable)     
ifelse sticky?
[output  ((pc-at 0 1) = black) and    ; if sticky? (a slider variable) is 0, then
         ((pc-at 0 -1) = black) and    ;   the turtle is free if its eight
         ((pc-at 1 0) = black) and    ;   neighboring patches are black
         ((pc-at -1 0) = black) and
         ((pc-at 1 1) = black) and
         ((pc-at 1 -1) = black) and
         ((pc-at -1 1) = black) and
         ((pc-at -1 -1) = black)]
 [output pc-ahead = black]       ; if sticky? is 1, a turtle is free if the
                                                     ;   patch directly ahead of it is black
end

to go-simple
ifelse free-simple
  [fd 1]
  [bk 1 place]
end

to free-simple
lt random wiggle
rt random wiggle
output pc = black
end

to place
set particles particles + 1
setc 15 + 10 * (round (particles / 500))          ; colors itself and the patch beneath it
stamp color                                       ;   according to particle number
if sound? = 1 [play-sound "drip"]
ht
setxy 0 0                                         ; moves the turtle to a random position on a
seth random 360                                   ;   circle inscribed in the screen, and assigns
fd screen-half-width                              ;   the turtle a random heading
st
seth random 360
end


`observer`
globals [particles]

to setup
ca                                       ; initializations
set particles 0
crt 25                                   ; setup small cluster to facilitate aggregation
ask-turtles [setup]
end


`information`
WHAT IS IT? -----------  
This program is a simulation of diffusion limited aggregation, where particles move randomly in the vicinity of a cluster until they collide with the structure and become part of it.  The simulation starts with a single particle in the center of the screen, and then other particles are given random headings and positions positions (along a circle inscribed in the screen) and are moved forward until they collide with another particle.  Particles are colored by their age, and the resulting formation is a dendritic fractal.   

HOW TO USE IT -------------  
The SETUP button colors a few particles in the middle of the screen and prepares the program to run.  The GO button sends particles in motion.  The WIGGLE slider controls the maximum amount of a particle's random heading adjustment with each time step.  The STICKY? slider differentiates between two alternative detection methods for when a particle has collided with the group.  When set to 0, a particle stops moving when any of the surrounding eight patches is occupied by a particle; when set to 1, a particles stops moving only when the patch directly in front of it is occupied.  

THINGS TO NOTICE ----------------   
The fractal dimension decreases with higher values of wiggle, as random motion increases the probability of colliding with a particle on the outside of the structure.  Similarly, the fractal dimension is lower with sticky? set to 0, as particles are more likely to be caught on the periphery of the cluster.  With certain parameters, the model can create aggregations that closely reflect the 1.7 fractal dimension that is often found in nature.


`interface`
SLCanvas
top-left 2 237

SLButton
turtle-or-observer? turtle
top-left 114 13
width-height 90 35
name "button2"
line-to-run "go"
forever? true
button-number 3
show-name? false
whichip 7

SLButton
turtle-or-observer? turtle
top-left 113 121
width-height 90 36
name "button3"
line-to-run "go-simple"
forever? true
button-number 4
show-name? false
whichip 8

SLSlider
top-left 72 14
width-height 86 25
name "slider2"
variable "sound?"
min-value 0
max-value 1
current-value 0
slider-number 2
show-name? false

SLButton
turtle-or-observer? observer
top-left 24 12
width-height 84 36
name "button1"
line-to-run "setup"
forever? false
button-number 2
show-name? false
whichip 9

SLSlider
top-left 30 117
width-height 90 25
name "slider0"
variable "sticky?"
min-value 0
max-value 1
current-value 1
slider-number 0
show-name? false

SLSlider
top-left 73 119
width-height 90 25
name "slider1"
variable "wiggle"
min-value 1
max-value 5
current-value 2
slider-number 1
show-name? false


`turtle shapes`
[encoded data, 5200 characters]
DhUAABUO2Q==

`template`
null

`settings`
patch-size 4
num-shapes 256
screen-half-width 50
screen-half-height 50
interface-window-xcor 231
interface-window-ycor 141
interface-window-size 660 415
output-window-xcor 0
output-window-ycor 0
output-window-width 300
output-window-height 219
info-window-xcor 144
info-window-ycor 126
info-window-width 500
info-window-height 419
control-center-xcor 15
control-center-ycor 71
control-center-width 345
control-center-height 491
turtle-command-center-height 140
observer-command-center-height 143

`string table`
H4sIAAAAAAAAAGNgYGBkYEkpyiwAALq4drcKAAAAAAAACg==

`symbol table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`double table`
H4sIAAAAAAAAAGNgYGByaMlgAIH9H8AUAwClB0DlFAAAAAAAABQ=

`list table`
H4sIAAAAAAAAAG1OQQ6AIAzrNg7GA569+D7/Hx9gF4ZbiCSlTbcWAGwATHgFTlJT
SmqbjMG+cknokvm0pv7zsGRlzrT4Wvza5SPJf1jt4unLuwexDy2PRLZlp/u3w8Mv
la+9mQgBAAAAAAEI

`bytecodes`
H4sIAAAAAAAAAI1UyVLCQBDtCckECBCCGVm1KOXqD3CyvPkXKEa0Cg0l4eA/6j85
S8+SwW2qhm66X7/ZXgeS1f17VazLh2K/uoYPMT4BoA3RvqgOO+7mYMYFnwR9gj9Z
gD63o1AagAggBgfMR4PPSwqQiiR8S+9Rkz7lEyw9UTwmziguQy2HpCcQbEoBsPFY
7wGH3GZo12Qdla5t3+EVubSB/AGEj29FwUNPR7snC5A7BDa2JzGxiTmNiKnVbs3J
lA2B5C30I143RJ+ijZ18U+ZJ/xz/63jbwSQepoO262B6HiZF23cwmYcZoD1xMLmH
YWhPHczQw4zQjh3MxGJS4rxMG/NTtDNe00P/TN2VxpvXakBrU17tn19220ItVxNF
9E9RNK3mWfcPgYSQCIHYRQe/6GRiiF3tkFxjA3suSR5BtNverQXt8pg2I04DWQrI
tLyszIzETI1oLNFgUz4DbDIuAcavONd1sZKuI7/6vfEnXAR4H9yyMyNJLUfZuChF
ddwRkBneN9Oy6JqcOjaF5OZQVeXrcj6X3d3yujXwHoOa5MAptG/i14c/1vdMvf5q
6ZraEMEva4ikOFEFAAAAAAVR

`observer world`
H4sIAAAAAAAAAGMQSMhPKk4tKkstUiguSSxJTXBggAMrBq6CnPyS8syU9NQSIJ+F
gS0nNS+9JAPI5mFgB8kVpOaBlXKDNcNlOYCYkYGzILGoJDM5J7UYaiAjCDMBCQDT
N0V0dwAAAAAAAHc=

`patch world`
[encoded data, 31915 characters]
sPPdzp37BAAABPud

`turtle world`
H4sIAAAAAAAAAI2Ta0hTcRTAT21zPqatXJm4YojZCB02t3yM2snmfFSYvfCLuOW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