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 (eco1.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: eco1.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]
turtles-own [mobility energy]
globals [halt]             ; set halt to true to stop simulation

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

;initialize all patches and turtles
to init
  ca                         ; clear all patches & kill all turtles
  init-globals
  crt 100
  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
end

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

to init-globals
  ; init globals here
  set halt false
end

to init-patch
  set penergy random 100
  set pcolor scale-color green penergy 200 0
end

to init-turtle
   set mobility 2
   set energy 100
   ;set metabolism random max-metabolism
   setxy random-xcor random-ycor
   set color scale-color red energy 200 0
   set shape "turtle"
end


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

to update-patch
   ifelse 100 - penergy < grow-back-rate
   [
     set penergy 100
   ]
   [
     set penergy penergy + grow-back-rate
   ]
   set pcolor scale-color green penergy 200 0
end

to update-turtle
   move
   let energy-available [penergy] of patch-here
   let energy-needed 100 - energy
   ifelse energy-available < energy-needed
   [
     set energy energy + energy-available
     ask patch-here [set penergy 0]
   ]
   [
     set energy 100
     ask patch-here [set penergy penergy - energy-needed]
   ]
   set color scale-color red energy 200 0
end

to update-globals
  ; change state of any globals
end

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

to move
  rt random 360
  fd mobility
  set energy energy - metabolism
  if energy <= 0 [print "a turtle died!" die]
end

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

to-report avg-energy
  report mean [energy] of turtles
end

to-report population
  report count turtles
end