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 20 times • Downloaded 1 time • 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.)


WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

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 23 days ago by Samuel Lin.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.