Model 1

No preview image

1 collaborator

Default-person Samuel Lin (Author)

Tags

(This model has yet to be categorized with any tags)
Model group Science Research | Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 1 time • Downloaded 0 times • Run 0 times
Download the 'Model 1' 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

patches-own [payoffmow payoffnomow trait] ;assigning the lawn a payoff if mow or if doesn't mow, and a trait

to setup
  clear-all
  reset-ticks
  set-default-shape turtles "flower"
end 

to go
  tick; move forward by one tick
  output-print(word  "\nRound " ticks)
  set-dandelion
  set-trait
end 

to set-dandelion
  let roll random 100    ;to prevent random from giving differenet values in my code
  if roll < p [
    output-print(word "Dandelions")
      if not any? turtles-on patch 0 0 [
       create-turtles 1 [
       set color yellow
       move-to patch 0 0
      ]
    ]
  ]
 if roll >= p [
    output-print(word "No Dandelions")
  ]
end 

; Note: MOWERS turn their lawn LIGHT GREEN
; DEFECTORS turn their lawn DARK GREEN

to set-trait
  ;; Check patch 0 0
  ask patch 0 0 [
    if any? turtles-here [
      set payoffmow (- c)
      set payoffnomow (- d)
    ]
   if not any? turtles-here [
      set payoffmow (- c)
      set payoffnomow 0
    ]

  output-print(word "payoffmow: " payoffmow)
  output-print(word "payoffnomow: " payoffnomow)

  ;; Decide trait
  if payoffmow > payoffnomow [
    set trait "Mower"
    output-print(trait)
    ask patch 0 0 [ set pcolor 66 ]
    if any? turtles-on patch 0 0 [
    output-print(word "Dandelions killed")
    ask turtles-on patch 0 0 [die]
      ]
  ]

  if payoffmow < payoffnomow [
    set trait "Defector"
    output-print(trait)
    if any? turtles-on patch 0 0 [
    output-print(word "Dandelions alive")
      ]
    ask patch 0 0 [ set pcolor 63 ]
  ]

  if payoffmow = payoffnomow [
    let coinflip random 2
    if coinflip = 0 [
      set trait "Mower"
      output-print(trait)
      ask patch 0 0 [ set pcolor 63 ]
      if any? turtles-on patch 0 0 [
      ask turtles-on patch 0 0 [die]
      output-print(word "Dandelions Killed")
        ]
    ]
    if coinflip = 1 [
      set trait "Defector"
      ask patch 0 0 [ set pcolor 66 ]
     if any? turtles-on patch 0 0 [
          output-print(word "Dandelions Alive")
    ]
  ]
    ]


  ]
end 

There is only one version of this model, created 1 day ago by Samuel Lin.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.