In order to add a new variable that you can act on in the model, you will need to create a new breed (eg. cars adding CO2 or plants removing CO2). Here are the commands, procedures & buttons you will need to setup/update:
create a new breed
create a new turtle shape & setup-default-shape (under setup)
create a procedure to add breed to model (eg. to add-newbreed)
create a procedure to remove breed to model (eg. to remove-newbreed)
add buttons to call add and remove breed procedures
add procedure to either absorb or release CO2 (eg. absorb-CO2 or release-CO2 & be sure to call procedure inside go procedure)
See code examples below. Remember to change the plants/plant breed to the name of your breed.
Place breed into model (create a button to call):
to add-plant
create-plants 1 [
set color green
set size 3
;; pick a random position on the ground
setxy random-xcor
earth-top + 2
]
end
Remove breed from model (create a button to call):
to remove-plant ;; randomly remove 1 plant
if any? plants [
ask one-of plants [die]
]
end
Absorb CO2 example (call procedure from go):
to absorb-CO2
ask CO2s [
if any? plants-here [die]
]
end
Create CO2 example (call procedure from go):
to release-CO2
ask plants [
if random 1000 = 0 [
hatch-CO2s 1 [
set color black
set size 1
setxy xcor ycor + 10
]
]
]
end
Get your breed moving example (add to setup code):
to move-plants [
setxy random-float 40 - 20 0
let coinflip random 2
ifelse coinflip = 0
[ set heading 90]
[ set heading -90 ]
]
end