This page was automatically generated by NetLogo 4.1. Questions, problems? Contact feedback@ccl.northwestern.edu.

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 Sun's Java site.


In order for this to work, this file, your model file (weboflife.nlogo), and the file NetLogoLite.jar must all be in the same directory. (You can copy NetLogoLite.jar 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 NetLogoLite.jar 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 NetLogoLite.jar 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: weboflife.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.


PROCEDURES

;++++++++++++++++++++++++++++
; initialization procedures
;++++++++++++++++++++++++++++

patches-own [penergy original-color dead]
turtles-own []
globals [num-patches halt]             ; set halt to true to stop simulation

;++++++++++++++++++++++++++++
; main procedures
;++++++++++++++++++++++++++++

;initialize all patches and turtles
to init
  ca                         ; clear all patches & kill all turtles
  ;crt 20                     ; create 20 turtles
  init-globals
  ask patches [init-patch]
  ask turtles [init-turtle]
end

; start button resumes & pauses iterations of this procedure
to update
  if halt [stop]
  tick                       ; advance clock by 1 second
  ask patches [update-patch]
  ;ask turtles [update-turtle]
  ;update-globals
  plot avg-penergy
end

;++++++++++++++++++++++++++++
; initialization procedures
;++++++++++++++++++++++++++++

to init-globals
  ; init globals here
  set halt false
  set num-patches count patches - 1
end

to init-patch
  ;init patch here
  set original-color one-of base-colors
  set pcolor original-color   ; for example
  set penergy 100
  set dead false
end

to init-turtle
  ; init turtle here
  pd                 ; for example
end


;++++++++++++++++++++++++++++
; update procedures
;++++++++++++++++++++++++++++

to update-patch
   ; change state of a patch
   if not dead [
   ask other patches 
   [
     if [penergy] of myself > 0
     [inc-penergy set-pcolor ask myself [set penergy penergy - 1 set-pcolor]]
   ]
   ]
   ;set penergy 1
   ;set-pcolor
end

to update-turtle
   ; change state of a turtle
   fd 1               ; for example
   rt 1               ; for example
end

to update-globals
  ; change state of any globals
end

;++++++++++++++++++++++++++++
; helper procedures
;++++++++++++++++++++++++++++

to inc-penergy 
  if not dead and penergy < 100 [set penergy penergy + 1]
end

to set-pcolor
  if not dead [set pcolor scale-color original-color penergy 0 100]
end

to spill-oil
  ask n-of random 20 patches [set dead true set pcolor black]
end

to-report avg-penergy
  report mean [penergy] of patches
end