s-fractal


Information

Created with NetLogo version NetLogo 4.0
Running with NetLogoLite.jar version 404.


WHAT IS IT?


-------
Inspired by something from Wolfram's NKS.

HOW IT WORKS


--------
A block is create.
Each "go", all blocks split in two, rotate 45 degrees, shrink ( 1 / sqrt 2) and shift 1 / sqrt 2 forward or backward.
Each cycle the shape gets more complex.

HOW TO USE IT


---------
Click Setup
Then click "go once" or "go many".
Use the various coloring buttons.
Click zoom.
The "cull rule" causes turtles that are "over crowded" to die.
The radius controls how far out the turtles look
The limit is the number of turtles within that radius that when exceeded causes the turtle to die.

Procedures

NetLogo Version: NetLogo 4.0

globals
[ pixel
  pixels-per-patch
  sqrt2
  invsqrt2
  generations
]

turtles-own
[ generation age ]

to startup setup end



to setup
   ca
   set sqrt2 sqrt 2
   set invsqrt2 1 / sqrt2
   create-turtles 1
   [ setxy 0 0
     set size world-height * .63
     set shape "square"
     set heading 0
     set color .color
   ]
   set pixels-per-patch 3
   set pixel 3 / pixels-per-patch
end

to go
   if zero-turtles [ stop ]
   if ( [ size * invsqrt2 < pixel ] of one-of turtles ) [ stop ]
   thing
   if ( use-cull-rule? ) [ cull ]
   do-tight-rule
   tick
   set generations generations + 1
end

to thing
   ask turtles
   [
     set size size * invsqrt2
     rt 45
     jump size * -.5
     hatch 1
     [ jump size
       set age 1
       set generation generation + 1
       set color color + 10
     ]
     set age age + 1
   ]
end

to cull
 ask turtles with [ count turtles in-radius (size * radius ) >= limit ]
 [ die ]
end

to do-tight-rule
   if  ( tight? and [ size < 25 ] of one-of turtles )
   [ ask patch 0 0
     [ ask turtles with [ distance myself > 100 ]
       [ die ]
     ] 
   ]
end
   
;; ===================================
;; special effect
;; ===================================

to zoom
   if zero-turtles [ stop ]
   let lens world-height * .45 * invsqrt2
   ask turtles
   [ let d distancexy 0 0 
     ifelse ( d > lens ) [ die ]
     [ let h heading
       facexy 0 0
       bk ((d * sqrt2) - d)
       set heading h
       set size size * sqrt2
     ]
   ]
end


to color-by-neighbor
   if zero-turtles [ stop ]
   let r radius * [ size ] of one-of turtles
   let max-r 3 * radius * radius
   ask turtles
   [ set color scale-color .color
       (count turtles in-radius r) -1 max-r
   ]
end

to-report zero-turtles
   report not any? turtles
end   
            

                    


Download Link

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