Monday, September 16, 2013

net logo

playing around with netlogo like was assigned in class.  I'm taking the genDrift P local program and adding in mutation to it.  Here is the code:

to setup
  clear-all
  ask patches  ;; randomly set the patches' colors
    [ set pcolor (random colors) * 10 + 5
        if pcolor = 75  ;; 75 is too close to another color so change it to 125
          [ set pcolor 125 ] ]
  reset-ticks
end

to go
  ask patches [
    ;; each patch randomly picks a neighboring patch
    ;; to copy a color from
    set pcolor [pcolor] of one-of neighbors
  ]
 
 
  if (ticks mod 10000) = 0
  [
    ask n-of 1000 patches [ set pcolor (random colors) * 10 + 5]
  ]
  tick
;;  move-to one-of patches with [pcolor = (random colors) * 10 + 5] ;; randomly set the patches' colors
;;    [ set pcolor (random colors) * 10 + 5
;;        if pcolor = 75  ;; 75 is too close to another color so change it to 125
;;          [ set pcolor 125 ] ]
;;    ]
end


; Copyright 1997 Uri Wilensky.
; See Info tab for full copyright and license.

No comments:

Post a Comment