This page was automatically generated by NetLogo 5.0.5.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.

In order for this to work, this file, your model file (Blaha_2D.nlogo), and the files NetLogoLite.jar and NetLogoLite.jar.pack.gz must all be in the same directory. (You can copy NetLogoLite.jar and NetLogoLite.jar.pack.gz from the directory where you installed NetLogo.)

On some systems, you can test the applet locally on your computer before uploading it to a web server. It doesn't work on all systems, though, so if it doesn't work from your hard drive, please try uploading it to a web server.

You don't need to include everything in this file in your page. If you want, you can just take the HTML code beginning with <applet> and ending with </applet>, and paste it into any HTML file you want. It's even OK to put multiple <applet> tags on a single page.

If the NetLogoLite files and your model are in different directories, you must modify the archive= and value= lines in the HTML code to point to their actual locations. (For example, if you have multiple applets in different directories on the same web server, you may want to put a single copy of the NetLogoLite files in one central place and change the archive= lines of all the HTML files to point to that one central copy. This will save disk space for you and download time for your users.)

powered by NetLogo

view/download model file: Blaha_2D.nlogo


(a general understanding of what the model is trying to show or explain)


(what rules the agents use to create the overall behavior of the model)


(how to use the model, including a description of each of the items in the Interface tab)


(suggested things for the user to notice while running the model)


(suggested things for the user to try to do (move sliders, switches, etc.) with the model)


(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)


(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)


(models in the NetLogo Models Library and elsewhere which are of related interest)


(a reference to the model’s URL on the web if it has one, as well as any other necessary credits, citations, and links)




to setup
  set-patch-size (760 / world-size )
  resize-world 0 (world-size - 1) 0 (world-size - 1)
  if set-random-seed? [random-seed random-seed-number]
  ;; setting the list with all possible colors
  set all-colors [5 15 25 35 45 55 65 75 85 95 105 115 125 135]
  let x all-colors
  let y []
  ;; preparing list Y with starting set of colors; LENGTH of Y equals to slider variable INITIAL-COLORS
  repeat initial-colors[
    let z random (length x) 
    set y lput (item z x) y
    set x remove-item z x
  set all-labels [0 1 2 3 4 5 6 7 8 9 10 11 12 13]
  let xx all-labels
  let yy []
  ;; preparing list YY with starting set of labels; LENGTH of YY equals to slider variable INITIAL-LABELS
  repeat initial-labels[
    let z random (length xx) 
    set yy lput (item z xx) yy
    set xx remove-item z xx
  ;; give a birth to agents through patches
  let nn (agents-density * world-size * world-size  / 100)
  ask n-of nn patches[
    sprout 1[
      set color one-of y
      set label one-of yy
      ifelse (random-float 1) < individualist-chance [set individualist? true] [set individualist? false]
  ask turtles[
    ifelse random-radius?
    [set nei turtles in-radius (1 + random-float (nei-radius - 0.9))]
    [set nei turtles in-radius nei-radius]
  ;; setting list COLORS-DISSEMINATION
  ;; set number of individualists for monitoring purposes
  set individualists count turtles with [individualist? = true]
  ;; set number of all turtles as N
  set n count turtles

to go
  ;; 1] in one turn we randomly pick up one neigrborhood
  ;; 2] we check the color homogeneity of neighborhood
  ;; 3] in case it is not homogenous, we find style with smallest overall effort needed for change
  ;; // alternatively: we find modus
  ;; 4] style is picked out from list of neighbors styles, the individualists put new styles on the list, as well
  ;; 5] all neighborhood adopts the effortless style
  ;; (effortless = the least sum of distances from present style of turtle and the style on the list)
  ;; 6] tick, go to [1]
  ;; ad [1]
  ask one-of turtles[
  ;ask turtles[
    ;; firstly, we update individualists ad [4]
    ask nei with [individualist?][
      ;; version where individualists take one of possible solution regardless it is alternative or not:
      if individualist-change > random-float 1 [set color (one-of all-colors)]
      if individualist-change > random-float 1 [set label (one-of all-labels)]
    ;; preparing for ad [2]
    let x [color] of nei
    ;; ad [2]
    if (max x) != (min x)[
      ;; ad [3]
      let unified-color 0
      if mechanism = "1=effortless" [set unified-color effortless-style (nei) (x)]
      if mechanism = "2=modus" [set unified-color modes-style (nei) (x)]
      if mechanism = "3=randomMix" [
        ifelse random 2 = 1
          [set unified-color effortless-style (nei) (x)]
          [set unified-color modes-style (nei) (x)]
      ;; ad [5]
      ask nei[
        set color unified-color
        set updates (updates + 1)
    ;; preparing for ad [2] and ad [4]
    let xx [label] of nei    
    if (max xx) != (min xx)[
      ;; ad [3]
      let unified-label -1
      if mechanism = "1=effortless" [set unified-label effortless-style (nei) (xx)]
      if mechanism = "2=modus" [set unified-label modes-style (nei) (xx)]
      if mechanism = "3=randomMix" [
        ifelse random 2 = 1
          [set unified-label effortless-style (nei) (xx)]
          [set unified-label modes-style (nei) (xx)]
      ;; ad [5]
      ask nei[
        set label unified-label
        set updates (updates + 1)

  ;; ad [6]
  ;; checking whether one color dominates all turtles
  if ending? [stop]
  if minimal-updates? [if min [updates] of turtles > minimal-updates [stop]]

to monitor-dissemintion
  set colors-dissemination []
  foreach all-colors[
    set colors-dissemination lput (count turtles with [color = ?]) colors-dissemination
  set labels-dissemination []
  foreach all-labels[
    set labels-dissemination lput (count turtles with [label = ?]) labels-dissemination

;; ad [3] and ad [4]
to-report modes-style [y xList] ;; Y is agentset NEI
  ;; USED COLORS/LABELS: presently used colors/labels in neighborhood are recorded in xList
  ;; now, we report the modus - in case we have more than 1 mode, we choose on of them randomly
  report one-of modes xList

;; ad [3] and ad [4]
to-report effortless-style [y xList] ;; Y is agentset NEI
  ;; xList is new and old values used inside NEI
  ;; for checking effortless value, we need to copy original eList to yList
  let yList xList
  ;; now we need to reduce the xList only to unique values
  set xList remove-duplicates xList
  ;; counting effort of whole NEI in case of changing COLOR/LABEL to every value from xList
  ;; no other than xList could be used, because Blaha said that all values should be lived and
  let effort []
  foreach xList[
    ;; Z is effort needed for change to respective color/label from the xList
    let xx ?
    let zList []
    foreach yList [set zList lput xx zList]
    let z 0
    (foreach yList zList [set z z + abs(?1 - ?2)])
    set effort lput z effort
  ;; now we find the position of minimal effort and doing so we find the effortless color
  let p position (min effort) effort
  report item p xList

to-report ending?
  ;; value of ENDING? will be TRUE when all turtles will have same color,
  ;; it means that for one color will hold TRUE that number of tortles of this color equals to number of all turtles
  ;; for all the other colors it will hold FALSE 
  ;; initializing list M where we will save logical value whether respective color is used by all turtles
  let m []
  ;; rolling over list M and saving logical values whether respective colors are used by all turtles
  ;; number of all turtles is set at setup phase as N
  foreach all-colors[
    set m lput (n = count turtles with [color = ?]) m
  ;; reducing list M, we are only interested in whether all values are FALSE, or one value of them is TRUE
  set m remove-duplicates m
  ;; we know that only one color could be TRUE, it means used by all turtles, in that case LENGTH of lis M is 2
  ;; otherwise list M consists of only FALSE values and after reduction its LENGTH equals to 1
  ;report length m = 2
  ;; so, in case one color is used by all turtles LENGTH of list M is 2 and procedure ENDING? reports value TRUE
  ;; now we have 2 traits, so we also prepare list MM for the labels and do the same for labels
  let mm []
  foreach all-labels[
    set mm lput (n = count turtles with [label = ?]) mm
  set mm remove-duplicates mm
  ;; now we reports the both traits are same, it means we sum length of both lists and check the sum against number 4, 
  ;; which means value TRUE is on the both lists
  report (length m + length mm) = 4