butterflies and human interaction

butterflies and human interaction preview image

1 collaborator

Default-person waqas majeed (Author)

Tags

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

breed [peoples people]
breed [butterflies butterfly]
breed [food flowers]
breed [venom vpod]

butterflies-own[people_seen people_hit
health robustness speed_variation
per_vis_rad per_vis_ang
food_around_me closest_food
have_venom
vis_rand
]
food-own [amount]
patches-own [solid]

globals [rad
daytime starting_color current_color
  color_adjust color_range
  timer_reset
]

to setup
  clear-all
  reset-ticks
  set rad 5

  ;after rad addition globals added then setup this function
  set timer_reset 1000
  set daytime true
  set starting_color 85
  set current_color starting_color
  set color_range 5
  set color_adjust ( color_range / ( timer_reset + 10 ))


  create-peoples number_of_people[
    setxy random-xcor random-ycor
    set color grey
    set size 10
    set shape "person"
  ]
  create-butterflies number_of_butterflies[
    setxy random-xcor random-ycor
    set color blue
    set size 10
    set shape "butterfly"

    ;making butteflies unique
    set health 50 + random 50
    adjust_vision_cone
    set robustness random 10
    set speed_variation random 10
    set heading 0
    pendown
    set vis_rand random 20
  ]

  create-food 10[
    grow_food
  ]
  create-venom 20 [
    make_venom
  ]
  draw_building
end 

to draw_building
  ask patches [
    set solid false
  ]
  ask patches with [ pxcor >= -30 and pxcor <= 30 and pycor >= -30 and pycor <= 30][
    set pcolor brown
    set solid true
  ]
end 

to grow_food
  setxy random-xcor random-ycor
  set color yellow
  set size 10
  set shape "plant"
  set amount random 100
end 

to make_venom
  setxy random-xcor random-ycor
  set color green
  set size 5
  set shape "x"
end 

to pickup_venom
  let pickup [false]
  ask venom in-radius rad [
    set pickup true
    die
  ]
  if pickup = true [
    set have_venom have_venom + 1
  ]
end 

to go
  make_people_move
  reset_patch_color
  make_butterflies_move
  grow_more_food
  tick
end 

to make_people_move
  ask peoples[
    set color grey
    right (random pwr -( pwr / 2))
    detect_wall
    forward people_speed
  ]
end 

to make_butterflies_move
  ask butterflies [
    ifelse health > 0 [
      show_visualisations
      pickup_venom
      set color blue
      let have_seen_person people_function
      let can_smell_food food_function 30
      ifelse ( have_seen_person = true ) [
        right 180
      ][
       ifelse ( can_smell_food = true ) and ( health < 100)[
        set heading ( towards closest_food )
      ][
        right (random bwr - (bwr / 2))
    ]]
       adjust_vision_cone
       detect_wall
       forward butterflies_speed + ( speed_variation * 0.1)
    ][
      set color gray
      die
    ]
  ]
end 

to grow_more_food
  if ticks > timer_reset [
    ask patch random-xcor random-ycor[
      sprout-food 1 [grow_food]
    ]
    ifelse daytime = true [
      set daytime false
    ][
      set daytime true
    ]
    reset-ticks
  ]
end 

to show_visualisations

  if show_col_rad = true[
      ask patches in-radius rad [
     if solid = false [
      set pcolor orange
      ]
    ]
    ]


  if show_vis_cone = true[
      ask patches in-cone per_vis_rad per_vis_ang[
      if solid = false [
      set pcolor red
      ]
    ]
    ]
end 

to reset_patch_color

  ifelse daytime = true [
    set current_color current_color - color_adjust
  ][
  set current_color current_color + color_adjust
]
 ask patches [
    if solid = false [
  set pcolor current_color
    ]
]
end 

to detect_wall
  if [solid] of patch-ahead 1 = true [
    right 180
  ]
end 

to adjust_vision_cone
   if ((((vis_rad + vis_rand)*(health * 0.01))) - ((starting_color - current_color) * 2) > 0) [
     set per_vis_rad (((vis_rad + vis_rand)*(health * 0.01))) - ((starting_color - current_color) * 2)
  ]
   if ((vis_ang + vis_rand)*(health * 0.01)) > 0 [
      set per_vis_ang (( vis_ang + vis_rand)*(health * 0.01))
  ]
end 

to-report people_function
  let seen [false]
  let hit [false]
  let person_hit 0

  ask peoples in-cone vis_rad vis_ang[
      set color green
      set seen true
    ]

    ask peoples in-radius rad[
      set hit true
      set person_hit who
      show person_hit
    ]
  ifelse seen = true [
      set people_seen people_seen + 1
      set color white
     ; right 180
    ][
      ;right (random bwr - (bwr / 2))
    ]

    if hit = true [
    ifelse have_venom > 0 [
      ask people person_hit [die]
      set have_venom have_venom - 1
    ][
      set people_hit people_hit + 1
      set color green
      set health health - robustness ;++++++
      adjust_vision_cone
    ]
  ]
  report seen
end 

to-report food_function [senstivity]
  set food_around_me other ( food in-radius senstivity )
  set closest_food min-one-of food_around_me [distance myself]
  let can_smell_food [false]
  let eating_food [false]

  if health < 100 [
    ask food in-radius rad [
      ifelse amount > 0 [
        set eating_food true
        set amount amount - 5
        set color color - .25
      ][
        die
      ]
    ]
  ]
  if eating_food = true [
    set health health + 5
    adjust_vision_cone
  ]
  if ( closest_food != nobody) [
    set can_smell_food true
  ]
  report can_smell_food
end 

There is only one version of this model, created 6 months ago by waqas majeed.

Attached files

File Type Description Last updated
butterflies and human interaction.png preview Preview for 'butterflies and human interaction' 6 months ago, by waqas majeed Download

This model does not have any ancestors.

This model does not have any descendants.