4 LDT students walk into a lab. Sounds like the beginning of a joke, no? Its not. This is very very serious.

BigK and Riki, having been in an exhibit design class last quarter, noticed emergent behavior in a set of nightlights. These were no special nightlights, but nightlights that have sensors on them. During the day, when the sensors are flooded with light, the light bulbs stay off. In the night, when the vampires stop glittering, the light bulbs turn on and light our paths to the bathroom. If you get a few of these special nightlights together, funny things start to happen: “http://vimeo.com/11545856
Our team wondered: What would it look like to model this phenomena in a Netlogo simulation?

Cue brainstorming! After experimenting with the gogo board, our four intrepid heroes decided to try to combine the virtual with the physical. Could they have a light and sensor, in the “real world”, that would join in the flickering dance with the virtual nightlights? Nothin’ to it but to do it.
The LDT students bought some nightlights, went in to a dark room, told each other secrets, and observed the flickering of the lights. Back and forth they went, trying to describe what was happening with the nightlights. The fact that the nightlights could be made to flicker slower and faster was initially very confusing, and resulted in changing of the code.  The emergent patterns created by the nightlights also proved to be a great visual demonstration of the power of a system: individually the night lights were dumb, simple creatures with only the potential to turn on and off.  But combined into a system, they gain the power to create a language of their own and develop amazing patterns.
In the spirit of “Fail often, fail early” some early test sessions were held in the depths of TermanB20.  With some assistance from professional tinkerer and Professor extraordinaire Blikstein, we learned how to modify our sensors so that they were connected to the GoGo board.  After running through various options that included using webcams, programming different kinds of night lights, and various other apparatus, the team decided to revert to the original plan of melding an array of virtual night lights with an array of real world lights to see how their patterns affected each other.
Stardate May 7th 2010:  7 PM- 1AM:  With much laughter, coding and physical assembly of a night light array, our intrepid band of bifocal adventurers forged on late into the night.  Disaster struck when the drivers for the GoGo board failed to load, and a net based treasure hunt ensued.  Hope was not lost and the driver was eventually found in the treasure hoard of an angry troll and successfully installed.  With the Gogo board set-up and the night light array arranged in the “Flickr” formation, all that was left to do was to connect the real to the virtual and watch what happened! http://vimeo.com/11548984

The secret Documents:  (i.e our code…)

extensions [gogo]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

breed [night-lights night-light]

breed [sensors sensor]

breed [lights light]

night-lights-own [my-intensity]

lights-own [my-intensity]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

globals [

serial-port ;; different on different operating systems

]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup

if enable-gogo?

[

set serial-port user-one-of “Select a port:” gogo:ports

gogo:open serial-port

repeat 5

[ if not gogo:ping


[ user-message “The GoGo Board is not responding.” ] ]

gogo:talk-to-output-ports [ “a” “b” “c” “d” ]

set-current-plot “Sensors”

]

clear-all

ifelse random-placement?

[gen-night-lights]

[gen-night-lights-test]

end

to gen-night-lights

create-night-lights num-night-lights

[


set shape “light”


set size scale


set color black


setxy random-xcor random-ycor

]

end

to gen-night-lights-test

create-night-lights 1

[


set shape “light”


set size scale


set color black


setxy light-radius 0


set heading 0

]

create-night-lights 1

[


set shape “light”


set size scale


set color black


setxy (-1 * light-radius) 0


set heading 90

]

create-night-lights 1

[


set shape “light”


set size scale


set color black


setxy 0 light-radius


set heading 180

]

create-sensors 1

[


set shape “light-sensor-only”


set size scale


setxy -.5 * light-radius -1 * light-radius


set heading 0

]

create-lights 1

[


set shape “light-bulb-only”


set size scale


setxy .5 * light-radius -1 * light-radius


set heading 0


set color black

]

end

to go

if (ticks mod 200 = 0)

[


clear-lights


ifelse random-placement?


[draw-lights]


[show-night-lights-test]


if not random-placement?

[


trip-virtual-sensor

]

]

tick

end

to show-night-lights-test

ask night-light 0

[


set size scale


setxy light-radius 0

]

ask night-light 1

[


set size scale


setxy (-1 * light-radius) 0

]

ask night-light 2

[


set size scale


setxy 0 light-radius

]

ask sensor 3

[


set size scale


setxy -.5 * light-radius -1 * light-radius

]

ask light 4

[


set size scale


setxy .5 * light-radius -1 * light-radius

]

draw-lights

end

to clear-lights

ask patches [set pcolor black]

end

to draw-lights

ask night-lights

[


let sensation 0


let my-sensor patch-right-and-ahead -18 -23


if my-sensor != nobody

[


ask my-sensor

[


;set pcolor yellow


set sensation pcolor

]

]


draw-light-versus-threshold sensation

]

if enable-gogo?

[


ask lights

[


let sensation (500 – gogo:sensor 1) / 100


if sensation < 0 [ set sensation 0 ]


if sensation > 9.9 [ set sensation 9.9 ]


write sensation


write “”


draw-light-versus-threshold sensation

]

]

end

to draw-light-versus-threshold [sensation]

ifelse sensation > threshold


[set my-intensity 0]


[set my-intensity (10 – sensation)]


;;set my-intensity (10 – sensation)


print my-intensity


draw-light


;;let sensor patch-right-and-ahead -18 -23


;;if sensor != nobody

;;[


;;print sensor


;;ask sensor


;;[


;; set pcolor yellow


;;]

end

to trip-virtual-sensor

ask sensors

[


let sensation 0


let my-sensor patch-right-and-ahead -25 -9


;;ask my-sensor [set pcolor yellow]


if my-sensor != nobody

[


ask my-sensor

[


;set pcolor yellow


set sensation pcolor



;; print pcolor

]

]


write sensation


if enable-gogo?

[


ifelse sensation > threshold


[ print “OFF” gogo:talk-to-output-ports [ “d” ]
gogo:output-port-off ]


[ print “ON” gogo:talk-to-output-ports [ “d” ]
gogo:output-port-on]

]

]

end

to draw-light

;; intensity is 0 – 9.9

;; radius = x*intensity

;; first x = intensity

;; next x = intensity – 1

;; next x = intensity – 2, etc.

;print self

let intensity my-intensity

;print intensity

;; white is the brightest we can get

if intensity > 9.9 [set intensity 9.9]

;; set the color of the light-bulb to the maximum intensity

set color intensity

let radius intensity

set intensity 0

let angle 310

while [radius > 0]

[


ifelse radius < 1 [set angle 360] [set angle 310]


ask patches in-cone (((3 * scale) / 10) * radius) angle

[


set pcolor intensity

]


set intensity (intensity + 1)


set radius (radius – 1)

]

end