BeeSmart HubNet

No preview image

1 collaborator

Default-person Bryan Guo (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.2.0 • Viewed 433 times • Downloaded 25 times • Run 0 times
Download the 'BeeSmart HubNet' 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?

BeeSmart HubNet model is part of the BeeSmart Curricular Unit and the HubNet version of the BeeSmart Hive Finding model in NetLogo Model's library. For detailed description of the phenomenon modeled, please refer to the info tab of the BeeSmart Hive Finding model.

BeeSmart HubNet model focuses on the interaction among bees as they dance in the swarm. The interaction is usually misunderstood because people tend to think bees watch and compare multiple dances in order to find the best one to follow. BeeSmart HubNet model allows students to act as scout bees and see the world from bees' perspective, which helps the students understand the limitations of the bees both physically and cognitively.

HOW IT WORKS

At each tick, androids move around randomly by turning a random angle between [-15 15] and forward a random-float number that is less than 0.1. It also sees if there is any dancing agents within one step and is in its 30 degree cone of vision. If there is, the android may follow the dance based on a probability that is calculated according to the interest of the dancer. If the android decides to follow the dance, it sets its target as the target of the dancer, and fly out to evaluate the hive site that the dance is advocating by facing the target and forward one step at each tick. When the site is within 3 steps and 120 degree of the android's cone of vision, the android sets its interest as the quality of the hive and fly back to the swarm to dance for it.

Students basically follow the same set of rules as androids, except for a few decisions that the clients can make: when the model starts, students needs to "fly" out of the swarm in order to discover new potential hive sites. Students can control where their bees go by using the directional buttons on the clients. When stumbled upon a site, students can go back to the swarm and press the dance button to perform dances in order to promote the hive they discovered. As a bee dances, her interest declines. when the interest reaches zero, the bee stops dancing. At this point, students can choose if they want to fly out and explore another hive or to stay in the swarm and follow other bees dances. They can follow other dances by clicking other dancing bees. Once a dance is selected, the bee automatically flies out to the site the dance was advocating, investigates the site, and flies back to the swarm. Then the student can decide whether to dance for the site or to follow another dance.

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab) When the model is launched, ask clients to join, preferably before clicking the setup button, so that you don't give away the hive site locations. After clients have joined the model, set the number-of-sites and radius BEFORE clicking the setup button. Then click Go Setup initialize the model, adding hive sites into the view. Go starts the model. Only after Go is clicked can clients see the bees that they control. number-of-sites determines how may hive sites to put in the view. radius determines how far the clients can see from their perspective.

THINGS TO NOTICE

As the model runs, notice the change in the histogram. The leftmost bar represents the dances that support of the lowest quality site, while the rightmost bar represents the dances for the highest. Sites are discovered in random orders, so the bars starts out with random heights. However, as the process continues, supports gradually converge to the highest. The Support-Overtime plot shows this dynamic overtime.

THINGS TO TRY

Play this simulation with at least 3 people. A group of 10 would be ideal because is provides enough diversity to imitate the scout bees in a beehive. Try to start with a small number of hives (around 4 to 5) but a larger vision radius (5 to 7). Talk to your partners as you play. After you are familiar with this model, reduce the vision radius and play again. You can also increase the number of hives to increase the difficulty. Finally, use a vision radius of 1 and play the model without talking to any of your partners. This way, you can experience bees' physical and cognitive limitations. After each round of play, look at the plots on the server and debrief what you and your partners did, and what happened.

EXTENDING THE MODEL

The waggle dances in this model is represented by agents wiggling left and right. One possibility of extending the model is to use the actual waggle dance pattern that is found in the BeeSmart Hive Finding model to make the dances more realistic and informative.

NETLOGO FEATURES

This model uses the HubNet Architecture, especially the perspective reset feature (hubnet-send-follow). Notice that the layers of agents are determined by the order when they were declared. The later declared agents are on top of earlier declared ones.

RELATED MODELS

Guo, Y. and Wilensky, U. (2014). NetLogo BeeSmart - Hive Finding model. http://ccl.northwestern.edu/netlogo/models/BeeSmart-HiveFinding. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

CREDITS AND REFERENCES

Guo, Y. and Wilensky, U. (2014). NetLogo BeeSmart - Hive Finding model. http://ccl.northwestern.edu/netlogo/models/BeeSmart-HiveFinding. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Seeley, T. D. (2010). Honeybee democracy. Princeton, NJ: Princeton University Press.

Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.

Wilensky, U. & Stroup, W., 1999. HubNet.http://ccl.northwestern.edu/netlogo/hubnet.html. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [sites site]
breed [androids android]
breed [students student]

globals [
  color-list 
  histogram-list 
  site-list 
  best-site 
  best-discovered? 
  best-chosen? 
  dist-among-sites 
  total-steps 
  stop? 
  quality-list 
  bees
  ]

sites-own [ 
  quality 
  dist-to-center 
  true-color
  ]

students-own [ 
  dancing-time
  dances-made
  user-id 
  target 
  target-quality 
  dist-to-hive
  interest 
  beetimer
  dancing? 
  re-visiting? 
  returning?
  recovering?
  myhome
  ]

androids-own [
  recovering? 
  myhome 
  target 
  target-quality 
  interest 
  dist-to-hive 
  beetimer
  dancing? 
  re-visiting? 
  returning?
  ]
patches-own [pdist-to-center ptype]

to startup
  hubnet-reset
    set-default-shape students "bee"
  set-default-shape androids "bug"
end 

to setup
  clear-patches
  clear-drawing
  clear-output
  clear-all-plots
  ask androids [die]
  set stop? false
  set best-discovered? false
  set best-chosen? false
  set color-list [97.9 94.5 57.5 63.8 17.6 14.9 27.5 25.1 117.9 114.4] 
  set quality-list [95 55 35 5 85 75 65 45 15 25]
  setup-patches
  if any? sites [ ask sites [die]] setup-sites
  if any? androids [ask androids [die] make-androids]
  ask students [
    reset-students
    send-info-to-clients
    ]
  make-androids
  set histogram-list []
  make-bee-list
  reset-ticks
end 

to make-bee-list
  let student-list students
  let android-list androids
  let bee-list sentence student-list android-list
  set bees turtle-set bee-list 
end 

to make-androids
  create-androids 100 [
    set color gray
    set target nobody
    set dancing? false
    set re-visiting? false
    set returning? false
    set recovering? false
    fd random-float 4
    ]
end 

to android-move
  if not re-visiting?  [
  ifelse [pcolor] of patch-here > 35 [facexy 0 0 fd 0.1][ if not dancing? [rt random 30 - 15 fd random-float 0.1]]
  ]
end 

to android-follow
  if not recovering? [
  if any? bees with [dancing?] in-cone 1 30 [
    let bee-watched one-of bees with [dancing?] in-cone 1 30
    if random 100 < [interest] of bee-watched [ ; interest declines over time, but target quality don't 
      set label "?"
      set target [target] of bee-watched
      set color [color] of target
      set myhome one-of patches with [ptype = "dance-floor"]
      set re-visiting? true
      ]
    ]
  ]
end 

to go
  if stop? [stop]
  listen-clients
  make-bee-list
  ask students [
    explore
    revisit
  ] 
  ask-concurrent bees [if dancing? [ifelse breed = students [dance][android-dance]]] 
  ask sites [count-bees]
  ask androids [if not dancing? [
      android-move
        android-follow
        revisit
        recover
      ]
  ]
  calculate-histogram-list
  plot-histogram
  plot-linegram
  tick
end 

to recover
  if recovering? [
  ifelse beetimer > 0 [
    set beetimer beetimer - 1
    ][
    set recovering? false
    ]]
end 

to calculate-histogram-list
  set histogram-list []
let offset [who] of min-one-of sites [who]
let site-quality-list sort [quality] of sites
  ask bees [
    if target != nobody and color != white [
    set histogram-list fput position target-quality site-quality-list histogram-list 
    ]
  ]
end 

to count-bees; site procedure
    if count students > 0 and count students in-radius 3 = count students [
      if self = best-site[
        set best-chosen? true
      ]
    ]
end 

to revisit
  if re-visiting? [
    ifelse returning? [
      ifelse distance myhome > 2 [
        face myhome fd 1
        ][
        set returning? false set re-visiting? false if breed = androids [set dancing? true]
        ]
    ][
    ifelse distance target < 1 [ 
      set target-quality [quality] of target          
      set interest round ([quality] of target / 10) ^ 2 
      set beetimer interest
      set color ([color] of target)
      set label "!"
      set returning? true
    ][
    fd 1                                       
    face target
    ]
    ]
  ]
end 

to explore; bee procedure
  ifelse any? sites in-cone 3 120 [
    ifelse color = gray or color = white [
    set target one-of sites in-cone 3 120 
    ask target [set color true-color]
    if target = best-site [set best-discovered? true]
    set target-quality [quality] of target ;;;;;;;;why do you need this?
    set interest round ([quality] of target / 10) ^ 2 
    set beetimer interest
    set dist-to-hive [dist-to-center] of target
    set label "!"
    set color [color] of target
    hubnet-send user-id "target-quality" target-quality
  ][
  hubnet-send user-id "Message" "Dance before you can discover another site"]
  ][hubnet-send user-id "Message" ""]
end 

to setup-patches
  ask patches [
    set pdist-to-center 4 * distancexy 0 0
    ifelse distancexy 0 0 < 4 [set pcolor scale-color brown pdist-to-center 0 30][set pcolor scale-color green pdist-to-center 0 100]
    if distancexy 0 0 < 3 [set ptype "dance-floor"]]
end 

to reset-students
  hubnet-send-follow user-id self radius 
    setxy random-float 5 random-float 5
    set dancing? false 
    set target nobody
    set re-visiting? false
    set returning? false
    set recovering? false
    set label ""
    set beetimer -1
    set dances-made 0
    set dancing-time 0
    set target-quality 0
    set color gray
    set myhome one-of patches with [ptype = "dance-floor"]
end 

to setup-sites
  create-sites number-of-sites [
    set color gray 
    set shape "box" 
    set size 2 
  ]
    set site-list sort sites 
    set dist-among-sites []
    let i [who] of min-one-of sites [who]  
    repeat count sites [
      ask site i [
        let mycolor one-of color-list
        set true-color mycolor 
        set color-list remove mycolor color-list
        set quality first quality-list + (random 10 - 4)
        set quality-list butfirst quality-list
      ]
      set-current-plot "support-overtime"  
      create-temporary-plot-pen word "site" i
      set-plot-pen-color [true-color] of site i 
      set i i + 1
    ]
    place-sites 
    set best-site max-one-of sites [quality]
    ask sites [set dist-to-center distancexy 0 0]
end 

to place-sites
  ask sites [ set-sitexy ]
  check-site-distance site-list
  let first-item first sort dist-among-sites
  if first-item < 10 [
    set dist-among-sites [] 
    place-sites
  ] 
end 

to set-sitexy
  ifelse random 2 = 0 [
    set xcor random-xcor
    ifelse random 2 = 0 [set ycor max-pycor - 1][set ycor min-pycor + 1]
  ][
  set ycor random-pycor
  ifelse random 2 = 0 [set xcor min-pxcor + 1][set xcor max-pxcor - 1]
  ]
end 

to check-site-distance [a-site-list]
  if length a-site-list > 1 [
    let i 1
    repeat length a-site-list - 1 [
    ask first a-site-list [set dist-among-sites fput distance item i a-site-list dist-among-sites] 
    set i i + 1
    ]
  set a-site-list butfirst a-site-list
  check-site-distance a-site-list
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;HubNet Procedures;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to listen-clients
  while [hubnet-message-waiting?]
  [
    hubnet-fetch-message
    ifelse hubnet-enter-message?
    [ create-new-student ]
    [
      ifelse hubnet-exit-message?
      [ remove-student ]
      [ ask students with [user-id = hubnet-message-source]
        [ execute-command hubnet-message-tag ]
      ]
    ]
  ]
end 

to create-new-student
  create-students 1
  [
    set user-id hubnet-message-source
    hubnet-send-follow user-id self radius 
    set target one-of sites
    set dancing? false
    set re-visiting? false
    set returning? false
    set recovering? false
    set color gray
    set myhome one-of patches with [ptype = "dance-floor"]
  ]
end 

to remove-student
  ask students with [user-id = hubnet-message-source]
  [ die ]
end 

to execute-command [command]
    
    if not dancing? [
  if command = "View"
  [
      let close-enough? false
      let choice min-one-of bees [distancexy item 0 hubnet-message item 1 hubnet-message]
      ask choice [if distancexy item 0 hubnet-message item 1 hubnet-message < 0.5 [set close-enough? true]]
      if close-enough? [
        if [dancing?] of choice [        
        set target [target] of choice
        set re-visiting? true 
        set label "?"
        set color ([color] of choice) ]
      ]
    ]
      if command = "dance" 
      [
        ifelse distancexy 0 0 < 4 [
          ifelse color = white [hubnet-send user-id "Message" "Visit or revisit a site to dance for it"][set dancing? true]
          ][
          hubnet-send user-id "Message" "I can only dance in the swarm."
          ]
        ]
      
    if color = white [
    if command = "revisit"
    [set re-visiting? true
      set color [color] of target]
  ]
  if not re-visiting? [
  if command = "up"
  [ execute-move 0 stop ]
  if command = "down"
  [ execute-move 180 stop ]
  if command = "right"
  [ execute-move 90 stop ]
  if command = "left"
  [ execute-move 270 stop ]
  ]
    ]
end 

to execute-move [new-heading]
  set heading new-heading
  fd 1
end 

to send-info-to-clients ;; turtle procedure
  hubnet-send user-id "target-quality" target-quality
  hubnet-send user-id "total-dances-made" dances-made
  hubnet-send user-id "total-dancing-time" dancing-time
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;DANCE;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to android-dance
    ifelse beetimer > 0 [
    face target
    rt interest
    wait 0.1
    lt interest
    wait 0.1
    lt interest
    wait 0.1
    rt interest
    wait 0.1
    set beetimer beetimer - 1
        ][
    set dancing? false
    set label ""
    set beetimer 20
    set color white 
    set recovering? true
    ]
end 

to dance 
  ifelse beetimer >= 0 [
    face target
    rt interest
    wait 0.1
    lt interest
    wait 0.1
    lt interest
    wait 0.1
    rt interest
    wait 0.1
    hubnet-send user-id "interest-in-target" beetimer
    set beetimer beetimer - 1
    set dancing-time dancing-time + 1
    hubnet-send user-id "total-dancing-time" dancing-time
    ][
  if beetimer < 0 [
    set dancing? false
    set dances-made dances-made + 1    
    hubnet-send user-id "total-dances-made" dances-made
    set label ""
    set color white
    ]
  ]
end 

to plot-histogram
  set-current-plot "support-count"
  create-temporary-plot-pen "pen"
  set-plot-pen-color green
  set-plot-pen-mode 1
  set-plot-x-range 0 count sites
  set-plot-y-range 0 number-of-sites
  set-histogram-num-bars count sites
  histogram histogram-list
end 

to plot-linegram
  set-current-plot "support-overtime"
  let i [who] of min-one-of sites [who]
  repeat count sites [
    set-current-plot-pen word "site" i
    plot count bees with [target = site i and color != white]
    set i i + 1
    ]
end 

There are 3 versions of this model.

Uploaded by When Description Download
Bryan Guo almost 9 years ago added info tab Download this version
Bryan Guo almost 9 years ago fully developed version Download this version
Bryan Guo almost 9 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Guo_Yu_BeeSmart_FinalReport.docx word EECS 472 Final Paper 2015 Spring almost 9 years ago, by Bryan Guo Download

This model does not have any ancestors.

This model does not have any descendants.