Bluebles3

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 110 times • Downloaded 7 times • Run 0 times
Download the 'Bluebles3' 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 [trees]  ;; keep track of how many trees there are
;; Blue Longneck Bluebles, Green Longneck Bluebles and Yeeblows are all breeds of turtle.

breed [bluelongneckbluebles bluelongneckblueble] 
breed [greenlongneckbluebles greenlongneckblueble] 
breed [yeeblows yeeblow]
turtles-own [energy]       ;;delete
patches-own [countdown]

to setup
  clear-all
  ask patches [ set pcolor 64 ]
    ask patches [
      set countdown random 10 ;; initialize trees grow clocks randomly
      set pcolor one-of [64 white] ;; green or white
    ]
 
   set-default-shape bluelongneckbluebles "longneck blueble"
  create-bluelongneckbluebles initial-number-bluelongneckbluebles  ;; create the blue 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 greenlongneckbluebles "longneck blueble"
  create-greenlongneckbluebles initial-number-greenlongneckbluebles  ;; create the green longneck 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 yeeblows "yeeblow"
  create-yeeblows initial-number-yeeblows  ;; create the yeeblows, then initialize their variables
  [
    set color yellow 
    set size 7  ;; easier to see
    set energy random 50
    setxy random-xcor random-ycor
  ]
  set trees count patches with [pcolor = 64]
  reset-ticks
end 

to go
  if not any? turtles [ stop ]
   ask bluelongneckbluebles [
    move
      set energy energy - 1  ;; deduct energy for bluelongneckbluebles 
      eat-trees
    death
    reproduce-bluelongneckbluebles
  ]
  ask greenlongneckbluebles [
    move
      set energy energy - 1  ;; deduct energy for greenlongneckbluebles
      eat-trees
    death
    reproduce-greenlongneckbluebles
  ]
  ask yeeblows [
    move
    set energy energy - 1  ;; yeeblows lose energy as they move
    catch-bluelongneckbluebles ;; yeeblows eat only blue longneck bluebles
    death
    reproduce-yeeblows
  ]
  ask patches [ grow-trees ] 
  set trees count patches with [pcolor = 64] ;; green
  tick
end 

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

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

to reproduce-bluelongneckbluebles  ;; bluelongneckbluebles 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-greenlongneckbluebles  ;; greenlongneckbluebles 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-yeeblows  ;; yeeblow procedure
  if random-float 100 < yeeblows-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-bluelongneckbluebles  ;; yeeblow procedure
  let prey one-of bluelongneckbluebles-here     ;; grab a random bluelongneckblueble
  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-trees  ;; patch procedure
  ;; countdown on white patches: if reach 0, grow some trees
  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 about 7 years ago by Kay Ramey.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.