Bluebles1

No preview image

1 collaborator

Default-person Kay Ramey (Author)

Tags

(This model has yet to be categorized with any tags)
Model group LS426-2012 | Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0RC7 • Viewed 305 times • Downloaded 22 times • Run 0 times
Download the 'Bluebles1' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [grass]  ;; keep track of how much grass there is
;; smoothbluebles, spinybluebles, longneckbluebles, greenbluebles and snurples are all breeds of turtles.
breed [smoothbluebles smoothblueble]
breed [spinybluebles spinyblueble]
breed [longneckbluebles longneckblueble] 
breed [greenbluebles greenblueble] 
breed [snurples snurple]
turtles-own [energy]       
patches-own [countdown]

to setup
  clear-all
  ask patches [ set pcolor 64 ]
    ask patches [
      set countdown random 10 ;; initialize grass grow clocks randomly
      set pcolor one-of [64 white] ;; green or white
    ]
  set-default-shape smoothbluebles "smooth blueble"
  create-smoothbluebles initial-number-smoothbluebles  ;; create the smooth bluebles, then initialize their variables
  [
    set color 105 ;; blue
    set size 7  ;; easier to see    
    set energy random 2
    setxy random-xcor random-ycor
  ]
   set-default-shape spinybluebles "spiny blueble"
  create-spinybluebles initial-number-spinybluebles  ;; create the spiny bluebles, then initialize their variables
  [
    set color 105 ;; blue
    set size 7  ;; easier to see    
    set energy random 2
    setxy random-xcor random-ycor
  ]
   set-default-shape longneckbluebles "longneck blueble"
  create-longneckbluebles initial-number-longneckbluebles  ;; create the longneck bluebles, then initialize their variables
  [
    set color 105 ;; blue
    set size 7  ;; easier to see    
    set energy random 2
    setxy random-xcor random-ycor
  ]
   set-default-shape greenbluebles "spiny blueble"
  create-greenbluebles initial-number-greenbluebles  ;; create the green bluebles, then initialize their variables
  [
    set color 64 ;; green
    set size 7  ;; easier to see    
    set energy random 2
    setxy random-xcor random-ycor
  ]
  set-default-shape snurples "snurple"
  create-snurples initial-number-snurples  ;; create the snurples, then initialize their variables
  [
    set color 115 ;; purple
    set size 7  ;; easier to see
    set energy random 50
    setxy random-xcor random-ycor
  ]
  set grass count patches with [pcolor = 64]
  reset-ticks
end 

to go
  if not any? turtles [ stop ]
  ask smoothbluebles [
    move
      set energy energy - 1  ;; deduct energy for smoothbluebles 
      eat-grass
    death
    reproduce-smoothbluebles
  ]
  ask spinybluebles [
    move
      set energy energy - 1  ;; deduct energy for spinybluebles 
      eat-grass
    death
    reproduce-spinybluebles
  ]
   ask longneckbluebles [
    move
      set energy energy - 1  ;; deduct energy for longneckbluebles 
      eat-grass
    death
    reproduce-longneckbluebles
  ]
  ask greenbluebles [
    move
      set energy energy - 1  ;; deduct energy for greenbluebles 
      eat-grass
    death
    reproduce-greenbluebles
  ]
  ask snurples [
    move
    set energy energy - 1  ;; snurples lose energy as they move
    catch-smoothbluebles
    death
    reproduce-snurples
  ]
  ask patches [ grow-grass ] 
  set grass count patches with [pcolor = 64] ;; green
  tick
end 

to move  ;; turtle procedure
  rt random 50
  lt random 50
  fd 1
end 

to eat-grass  ;; bluebles procedure
  ;; bluebles eat grass, turn the patch white
  if pcolor = 64 [ ;; green
    set pcolor white 
    set energy energy + 2 ;; bluebles gain energy by eating
  ]
end 

to reproduce-smoothbluebles  ;; smoothbluebles procedure
  if random-float 100 < bluebles-reproduce [  ;; throw "dice" to see if you will reproduce
    set energy (energy / 2)                ;; divide energy between parent and offspring
    hatch 1 [ rt random-float 360 fd 1 ]   ;; hatch an offspring and move it forward 1 step
  ]
end 

to reproduce-spinybluebles  ;; spinybluebles procedure
  if random-float 100 < bluebles-reproduce [  ;; throw "dice" to see if you will reproduce
    set energy (energy / 2)                ;; divide energy between parent and offspring
    hatch 1 [ rt random-float 360 fd 1 ]   ;; hatch an offspring and move it forward 1 step
  ]
end 

to reproduce-longneckbluebles  ;; longneckbluebles procedure
  if random-float 100 < bluebles-reproduce [  ;; throw "dice" to see if you will reproduce
    set energy (energy / 2)                ;; divide energy between parent and offspring
    hatch 1 [ rt random-float 360 fd 1 ]   ;; hatch an offspring and move it forward 1 step
  ]
end 

to reproduce-greenbluebles  ;; greenbluebles procedure
  if random-float 100 < bluebles-reproduce [  ;; throw "dice" to see if you will reproduce
    set energy (energy / 2)                ;; divide energy between parent and offspring
    hatch 1 [ rt random-float 360 fd 1 ]   ;; hatch an offspring and move it forward 1 step
  ]
end 

to reproduce-snurples  ;; snurple procedure
  if random-float 100 < snurples-reproduce [  ;; throw "dice" to see if you will reproduce
    set energy (energy / 2)               ;; divide energy between parent and offspring
    hatch 1 [ rt random-float 360 fd 1 ]  ;; hatch an offspring and move it forward 1 step
  ]
end 

to catch-smoothbluebles  ;; snurple procedure
  let prey one-of smoothbluebles-here           ;; grab a random smoothblueble
  if prey != nobody                             ;; did we get one?  if so,
    [ ask prey [ die ]                          ;; kill it
      set energy energy + 100 ]                 ;; get energy from eating
end 

to death  ;; turtle procedure
  ;; when energy dips below zero, die
  if energy < 0 [ die ]
end 

to grow-grass  ;; patch procedure
  ;; countdown on white patches: if reach 0, grow some grass
  if pcolor = white [
    ifelse countdown <= 0
      [ set pcolor 64
        set countdown 10 ]
      [ set countdown countdown - 1 ]
  ]
end 

There is only one version of this model, created over 12 years ago by Kay Ramey.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.