This page was automatically generated by NetLogo 5.0.4.

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.


powered by NetLogo

view/download model file: Sync.nlogo

WHAT IS IT?

This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT

This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE

This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY

This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL

This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

This section could contain a reference to the model’s URL on the web if it has one, as well as any other necessary credits or references.

CODE


globals [diam]

turtles-own
[
  charge ;
  timeLatent ;
]

to setup-globals  ; separate procedure for setting globals
  set diam 1
  set-default-shape turtles "circle"
end

to setup  ; Setup the model for a run, build a graph.
  ;; (for this model to work with NetLogo's new plotting features,
  ;; __clear-all-and-reset-ticks should be replaced with clear-all at
  ;; the beginning of your setup procedure and reset-ticks at the end
  ;; of the procedure.)
  __clear-all-and-reset-ticks
  setup-globals
  setup-turtles
  setup-plot
end

to setup-turtles
  crt numAgents [
    set label-color black
    set size diam
;    set label who
    setxy (random-float max-pxcor) * (1 - 2 * (random 2))
          (random-float max-pycor) * (1 - 2 * (random 2))
    set charge random-float threshold
    set color charge
    set timeLatent 0.0
  ]
end

to step
  ask turtles [
    ; think about whether we charge while latent
    if (timeLatent > latency)
    [
       set charge charge + 1
    ]
    set color (charge + 1) mod 139
    set timeLatent timeLatent + 1
    if (charge > threshold)
      [flash ]
  ]
  plot-counts
end

to flash
  set charge 0.0
  set timeLatent 0.0
  ask turtles with [ (distance myself) <= regionSize ]
          [ if  (timeLatent > latency)
            [ set charge charge + boost]
          ]
end

to plot-counts
  set-current-plot "charge-plot"
  set-current-plot-pen "default"
  histogram [charge] of turtles
end


to setup-plot
  set-current-plot "charge-plot"
  set-plot-x-range 0 1.1 * threshold
  set-plot-y-range 0 round ((count turtles) / 5)
  set-histogram-num-bars 40
end