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.


March 4th, 2014 CS 1025 example:
Feel free to view/download model file: PlotStarsCaterpillars.nlogo

CS 1025 students: To download the model, be sure to right mouse button click and Save As so you can then run it with the NetLogo application. Left mouse button click will just open the file so you can look at the code.

powered by NetLogo

view/download model file: PlotStarsCaterpillars.nlogo

WHAT IS IT?

Tuesday March 4th, 2014 example of using Monitors and Plots in NetLOGO. Hatching start and caterpillars, which are specialized breeds of turtles.

HOW IT WORKS

Right mouse button click on the view/download model link above if you want to play with this MODEL in NetLogo. Left mouse button click if you just want to look at all of the code.

HOW TO USE IT

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

THINGS TO NOTICE

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

THINGS TO TRY

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

EXTENDING THE MODEL

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

NETLOGO FEATURES

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

RELATED MODELS

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

CREDITS AND REFERENCES

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

CODE

breed [ stars star ]
breed [ caterpillars caterpillar ]
breed [ circles circle ]                 ;; had to create a new breed (CIRCLES) only circles can hatch stars or caterpillars


globals [ r starDist catDist cir]

to setup
  ca

  reset-ticks
  
  set starDist 6
  set catDist 3
  set cir 64
  
  
  if (doubleTheCircles) 
  [
     set cir (2 * cir) 
  ]
  
  create-ordered-circles cir
  [ 
     set shape "circle"
     fd 10
     set color white
  ]
END


TO GO
   if (count circles = 0) [ stop ]
   ask circles
   [
     set r random 100
     
     ifelse (r < 2)
     [
       hatch-stars 1 
       [ 
         ifelse (random 10 < 5) [set color white] [set color red] 
         set shape "star"
         set heading heading + (random 40 - 20)
         ifelse (random 10 < 5) [bk starDist] [fd starDist]         
       ]
       
       if ((random 100) < 1) [ die ]
     ]
     [
       if (r < 4)
       [
          hatch-caterpillars 1
          [
            ifelse (random 10 < 5) [set color orange] [set color green] 
            set heading heading + (random 40 - 20)
            ifelse (random 10 < 5) [bk catDist] [fd catDist]   
            set shape "caterpillar"            
          ]
       ]
     ]
   ]
   if (ticks = 5000) 
   [  
         set starDist starDist - 1 
         set catDist catDist - 1 
   ]
   
   if (ticks = 12000 and goBlue)
   [
      ask turtles [ set color blue ]
   ]
   
   tick
END