Tuesday, March 20, 2012

Project 3 presentation - 3/19

I decided to go with the catastrophe theory/hysteresis idea for Project 3. Using Netlogo, I created a simulation involving 3 different kinds of "brushes", all circular in shape, that would move around the "canvas" leaving trails of "paint" behind. Below is the look I was going for.

SuperStock_1147-379.jpg

There are 3 different kinds of brushes. One type always tends towards a "rage reaction" in a hysteresis simulation, and is colored yellow. Another type always tends towards a "fear reaction" and is colored green. The last brush does not tend either way and is colored purple. The "paint trails" left behind as the brushes move are colored to match their respective brushes. 

As the brushes move in random directions, they come in to contact with one another. When this happens, they go through a catastrophe theory hysteresis simulation. When brush A comes into contact with brush B, one of 2 things can happen. Depending on how many similarly colored brushes are in the immediate the vicinity of brush A and B, and the number of differently colored brushes in the immediate vicinity to brush A and B, the brushes will each change colors to either red or blue. The color red indicates a "fight reaction", and the color blue represents a "flight reaction". They then stay that color for a specific amount of time before reverting back to their original color. Interacting with other brushes along the way can also change their color. The change to red or blue is dependent on the brushes' tendencies towards rage or fear, and how many differently colored brushes are surrounding the brush in relation to how many similarly colored brushes.






If this work were in a gallery setting, I would most likely project only the "canvas" itself, while the program runs, so the simulation can be viewed in real time. It would be set on a timer so that after a certain amount of time it would start over.

Below is my code done in Netlogo:

globals [
  percent-similar
  percent-different
  time
  reds
  blues
]  
breed [yellows ragebrush]  ;; sheep is its own plural, so we use "a-sheep" as the singular.
breed [greens fearbrush]
breed [purples neutralbrush]
turtles-own [
  energy
  similar-nearby
  different-nearby
]
patches-own [countdown]



to setup
  clear-all
  set time 0
  set reds 0
  set blues 0
  ask patches [ set pcolor white ]
  set-default-shape yellows "circle"
  create-yellows rage-brushes [ setxy random-xcor random-ycor ]
  set-default-shape greens "circle"
  create-greens fear-brushes [ setxy random-xcor random-ycor ]
  set-default-shape purples "circle"
  create-purples neutral-brushes [ setxy random-xcor random-ycor ]
  ask yellows [set color yellow]
  ask greens [set color green]
  ask purples [set color violet]
  reset-ticks
end 

to go
  set time time + 1
  time-check
  move-turtles
  ask yellows [ catch-others ]
  ask greens [ catch-others ]
  ask purples [catch-others ]
  ask turtles [ change-color ]
  tick
end

to move-turtles
  ask yellows [
  right random 50
  left random 50
  fd 1
  set pen-size 2
    pd
  ]
  ask greens [
  right random 50
  left random 50
  fd 1
  set pen-size 2
    pd
  ]
  ask purples [
  right random 50
  left random 50
  fd 1
  set pen-size 2
    pd
  ]
end

to time-check
  if ( time > 10 )
    [ set time 0 ]
end
    
to catch-others
  set similar-nearby count (turtles-on neighbors)
    with [color = [color] of myself]
  set different-nearby count (turtles-on neighbors)
    with [color != [color] of myself]
  if breed = yellows[
    if (different-nearby > similar-nearby) and (different-nearby <= 2) [
      set color red
      set reds reds + 1
    ]
    if (different-nearby > similar-nearby) and (different-nearby > 2) [
      set color blue
      set blues blues + 1
    ]
  ]
  if breed = greens[
    if (different-nearby > similar-nearby) and (different-nearby <= 2) [
      set color blue
      set blues blues + 1
    ]
    if (different-nearby > similar-nearby) and (different-nearby > 2) [
    set color red
    set reds reds + 1
    ]
  ]
  if breed = purples[
    let randomizer random 10
    if (different-nearby > similar-nearby)[
       if randomizer < 6[
         set color red
         set reds reds + 1
       ]
       if randomizer > 5[
         set color blue
         set blues blues + 1
       ]
    ]
  ]
end

to change-color
  if breed = yellows and ( color = red or color = blue )[
    if ticks mod 10 = 0 [
      set color yellow
    ]
  ]
  if breed = greens and ( color = red or color = blue )[
    if ticks mod 20 = 0 [
      set color green
    ]
  ]
  if breed = purples and ( color = red or color = blue )[
    if ticks mod 20 = 0 [
      set color violet
    ]
  ]
end

No comments:

Post a Comment