Fruit Tree Growth in Different Soil pH (Using GoGo Board)

No preview image

1 collaborator

Nobita_square Brian Young (Author)

Tags

(This model has yet to be categorized with any tags)
Model group Stanford-BBA-Spr10 | Visible to everyone | Changeable by group members (Stanford-BBA-Spr10)
Model was written in NetLogo 4.1 • Viewed 172 times • Downloaded 17 times • Run 0 times
Download the 'Fruit Tree Growth in Different Soil pH (Using GoGo Board)' 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

extensions [gogo]

globals [
  serial-port   ;; different on different operating systems
]

breed [apples apple]
breed [blueberries blueberry]
breed [kiwis kiwi]
breed [mangoes mango]

apples-own [ energy phFactor]
blueberries-own [ energy phFactor]
kiwis-own [ energy phFactor]
mangoes-own [ energy phFactor]

to setup
  set serial-port user-one-of "Select a port:" gogo:ports
  gogo:open serial-port
  repeat 5
  [ if not gogo:ping
    [ user-message "The GoGo Board is not responding." ] ]
  gogo:talk-to-output-ports [ "a" "b" "c" "d" ]
  set-current-plot "Sensors"
  
  clear-all
  grow-water-and-nutrients
  set-default-shape apples "circle"
  create-apples apple-seed [
    set color red
    setxy random-xcor random-ycor
    set phFactor 5.75
    ifelse (abs ((gogo:sensor 1 / 100) - phFactor) < 1) [ set energy 20] [set energy 10]
  ]
  
  set-default-shape blueberries "circle"
  create-blueberries blueberry-seed [
    set color blue
    setxy random-xcor random-ycor
    set phFactor 4.5
    ifelse (abs ((gogo:sensor 1 / 100) - phFactor) < 1) [ set energy 20] [set energy 10]
  ]
  
  set-default-shape kiwis "circle"
  create-kiwis kiwi-seed [
    set color green
    setxy random-xcor random-ycor
    set phFactor 6.75
    ifelse (abs ((gogo:sensor 1 / 100) - phFactor) < 1) [ set energy 20] [set energy 10]
  ]
    
  set-default-shape mangoes "circle"
  create-mangoes mango-seed [
    set color orange
    setxy random-xcor random-ycor
    set phFactor 6.75
    ifelse (abs ((gogo:sensor 1 / 100) - phFactor) < 1) [ set energy 20] [set energy 10]
  ]
  setup-plot
  do-plot
end 

to gogo-ping
  carefully
  [ if not gogo:ping
    [ user-message "Unable to ping GoGo Board." ] ]
  [ user-message error-message ]
end 

to go
  if not any? turtles [ stop ]
  grow-water-and-nutrients
  ask turtles
  [ move
    eat-water
    eat-nutrients
    reproduce
    death ]
 
  
  tick
  do-plot
end 

to grow-water-and-nutrients
  ask patches [
    if pcolor = black [
      if random-float 1000 < nutrients-grow-rate
        [ set pcolor brown ]
      if random-float 1000 < water-grow-rate
        [ set pcolor cyan ]
  ] ]
end 

to move  ;; move procedure
  rt random 50
  lt random 50
  fd 1
  ;; moving takes some energy
  set energy energy - 0.5
end 

to eat-water  ;; water absorb procedure
  ;; gain "water-energy" by eating water
  if pcolor = cyan
  [ set pcolor black
    set energy energy + water-energy ]
end 

to eat-nutrients  ;; nutrient absorb procedure
  ;; gain "nutrient-energy" by eating nutrients
  if pcolor = brown
  [ set pcolor black
    set energy energy + nutrient-energy ]
end 

to reproduce     ;; growth procedure
  ;; give birth to a new fruit, but it takes lots of energy
  let factor phFactor
  
  if energy > birth-threshold
    [ set energy energy / 2
      hatch 1 [ 
        fd 1 
        ifelse (abs ((gogo:sensor 1 / 100) - phFactor) < 1) [ set energy 10 + pHadvantage] [set energy 10]
        ] ]
end 

to death     ;; apple procedure
  ;; die if you run out of energy
  if energy < 0 [ die ]
end 

;;; plotting procedures

to setup-plot
  set-current-plot "Populations"
  set-plot-y-range 0 100
end 

to plot-sensor-value [ plot-sensor ]
 if plot-sensor != "none"
 [
   set-current-plot-pen plot-sensor
   if plot-sensor = "sensor 1"
       [ plot (gogo:sensor 1) ]
   if plot-sensor = "sensor 2"
       [ plot (gogo:sensor 2) ]
   if plot-sensor = "sensor 3"
       [ plot (gogo:sensor 3) ]
   if plot-sensor = "sensor 4"
       [ plot (gogo:sensor 4) ]
   if plot-sensor = "sensor 5"
       [ plot (gogo:sensor 5) ]
   if plot-sensor = "sensor 6"
       [ plot (gogo:sensor 6) ]
   if plot-sensor = "sensor 7"
       [ plot (gogo:sensor 7) ]
   if plot-sensor = "sensor 8"
       [ plot (gogo:sensor 8) ]
  ]
end 

to do-plot
  set-current-plot "Populations"
  set-current-plot-pen "water"
  plot count patches with [pcolor = cyan] / 4
  set-current-plot-pen "nutrients"
  plot count patches with [pcolor = brown] / 4
  set-current-plot-pen "apples"
  plot count apples
  set-current-plot-pen "blueberries"
  plot count blueberries
  set-current-plot-pen "kiwis"
  plot count kiwis
  set-current-plot-pen "mangoes"
  plot count mangoes
  set-current-plot "Sensors"
  plot-sensor-value plot-sensor-1
end 

There is only one version of this model, created almost 14 years ago by Brian Young.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.