Bug Hunters Speeds

No preview image

2 collaborators

Uri_dolphin3 Uri Wilensky (Author)
Default-person Michael Novak (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.1pre1 • Viewed 163 times • Downloaded 12 times • Run 0 times
Download the 'Bug Hunters Speeds' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


VERSION

$Id: Bug Hunters Speeds.nlogo 37721 2008-02-05 02:11:31Z michelle $

WHAT IS IT?

This is a HubNet activity of natural/artificial selection model that shows the result of two competing forces on natural selection of the speed of prey. Which force dominates depends on the behavior of predators.

One force is that predators that chase prey, tend to catch slower moving prey more often, thereby selecting for prey that are faster over many generations of offspring.

Another force is that predators who wait for their prey without moving, tend to catch prey that are moving faster more often, thereby selecting for prey that are slower over many generations of offspring.

By also adjusting whether bugs try to avoid the predator and the predictability of their motion, a different one of these competing forces will tend to dominate the selective pressure on the population.

HOW IT WORKS

Each HubNet participant or player assumes the role of a predator. When the HubNet simulation is started after pressing GO, participants should try to click on bugs as fast as they can with the mouse.

Each participant can monitor his or her relative success compared to other participants by watching the monitors in the client that show the TOP HUNTER (the person with most catches), how many that person caught (TOP HUNTER'S CATCHES) and the RELATIVE % they have caught compared to the best hunter (e.g. if the player has caught 40 and the best hunter has caught 80, then s/he has 50%).

Press SETUP to create a population of bugs, determined by six times the INITIAL-BUGS-EACH-SPEED slider. These bugs that are created are randomly distributed around the world and assigned a speed.

When you press GO the bugs begin to move at their designated speeds. As they move around, try to eat as many bugs as fast as you can by clicking on them. Alternatively, you may hold the mouse button down and move the predator over the bugs.

The six different speeds that a bug might move at are distributed amongst six different sub-populations of the bugs. These speeds are inherited. With each bug you eat, a new bug is randomly chosen from the population to produce one offspring. The offspring is an exact duplicate of the parent (in its speed and location). The creation of new offspring keeps the overall population of the bugs constant.

Initially there are equal numbers of each sub-population of bug (e.g. ten bugs at each of the 6 speeds). Over time, however, as you eat bugs, the distribution of the bugs will change as shown in the "Number of bugs" histogram. In the histogram, you might see the distribution shift to the left (showing that more slow bugs are surviving) or to the right (showing that more fast bugs are surviving). Sometimes one sub-population of a single speed of bug will be exterminated. At this point, no other bugs of this speed can be created in the population.

HOW TO USE IT

To run the activity press the GO button. To start the activity over with the same group of students stop the GO button by pressing it again, press the SETUP button, and press GO again. To run the activity with a new group of students press the RESET button in the Control Center.

Make sure you selecv Mirror 2D view on clients in the HubNet Control Center after you press SETUP.

INITIAL-NUMBER-BUGS-EACH-SPEED is the number of bugs you start with in each of the six sub-populations. The overall population of bugs is determined by multiplying this value by 6.

SPEED-COLOR-MAP settings help you apply or remove color visualization to the speed of the bugs:

- The "all green" setting does not show a different color for each bug based on its speed". Keeping the color settings switched to something besides "all green" can tend to result in the predator (the user) unconsciously selecting bugs based on color instead of speed.

- The "rainbow" setting shows 6 distinct colors for the 6 different speeds a bug might have. These color settings correspond to the plot pen colors in the graphs.

- The "purple shades" setting shows a gradient of dark purple to light purple for slow to fast bug speed.

NUMBER OF BUGS is a histogram showing the distribution of bugs at different speeds.

BUGS CAUGHT is a histogram showing the historical record of the distribution of bugs caught at different speeds.

WIGGLE?, when set to "on" adds a small amount of random twist in the motion of the bugs as they move forward each time step.

FLEE?, when set to "on" has bugs turn around (to face in the opposite direction) when they detect your mouse click (as a predator) in their detection cone (an arc of 120 degrees that has a range of 2 units). Bugs can detect the predator only in this arc in front of them, and so will not react when caught from behind.

THINGS TO NOTICE

The CURRENT BUGS histogram tends to shift right (increasing average speed) if you assume the role of chasing easy prey.

The CURRENT BUGS histogram tends to shift left (decreasing average speed) if you assume the role of waiting for prey come to you. The same effect can also be achieved by moving the predator around the world randomly.

THINGS TO TRY

Set the model up with INITIAL-BUGS-EACH-SPEED set to one. Slow the model down and watch where new bugs come from when you eat (click mouse on) a bug. You should see a new bug hatch from one of the five remaining and it should be moving at the same speed as its parent.

Wait in one location for the bugs to come to you by placing the cursor in one location and holding down the mouse button. All bugs that run into you will be eaten.

Chase bugs around trying to catch the bug nearest you at any one time by holding the mouse button down and moving the cursor around the view after the nearest bug.

EXTENDING THE MODEL

The Bug Hunt Speeds model has bugs move in a straight line. It would be more difficult if bugs wandered in a path that is not a straight line and if the bugs avoided you (the predator). Both of these characteristics as well as speed are inheritable characteristics in the Bug Hunt Scurry model.

A HubNet version of the model with adjustable starting populations of bugs would help show what happens when two or more competitors assume similar vs. different hunting strategies on the same population at the same time.

RELATED MODELS

Bug Hunt Speeds

Bug Hunt Camouflage

Bug Hunters Camouflage

Peppered bugs

Guppy Spots

CREDITS AND REFERENCES

Inspired by EvoDots software:

http://faculty.washington.edu/~herronjc/SoftwareFolder/EvoDots.html

Comments and Questions

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

Click to Run Model

globals [
    total-caught                 ;; keeps track of total number of bugs caught
    total-speed-6-caught         ;; keeps track of the number of bugs caught with speed of 6
    total-speed-5-caught         ;; keeps track of the number of bugs caught with speed of 5
    total-speed-4-caught         ;; keeps track of the number of bugs caught with speed of 4
    total-speed-3-caught         ;; keeps track of the number of bugs caught with speed of 3
    total-speed-2-caught         ;; keeps track of the number of bugs caught with speed of 2
    total-speed-1-caught         ;; keeps track of the number of bugs caught with speed of 1
    time                         ;; keeps track of number of simulation steps that have passed
    old-color-map                ;; keeps track of the previous value of the SPEED-COLOR-MAP chooser
    histogram-interval-size      ;; the value of the interval size for each bar of the histogram
  leader
  leader-caught
  number-players
  last-ticks                    ;; what the the tick value was at the start of the
                                ;; current interval
  bugs-in-a-batch               ;; how many bugs must be caught in a batch. when this is reached,
                                ;; the time to reach this (the interval) is recorded
  interval-length               ;; how long it took to catch the last number of bugs-in-a-batch
  caught-in-current-batch       ;; how many bugs have been caught so far in this current interval
  batches                       ;; how many batches have been caught (for plotting)
  adult-age                     ;; the age at which recently hatched bugs become full sized
  ]

breed [ players player ]
breed [bugs bug]
bugs-own [speed]
players-own
[
  user-name
  caught
  attempts
  percent
]

to startup
  hubnet-set-client-interface "COMPUTER" []
  hubnet-reset
  set number-players 0
  setup-clear
end 

to setup-clear
  ca
  setup
end 

to setup
  cp
  clear-all-plots
  reset-ticks
  set total-caught 0
  set   total-speed-6-caught 0
  set   total-speed-5-caught 0
  set   total-speed-4-caught 0
  set   total-speed-3-caught  0
  set   total-speed-2-caught   0
   set   total-speed-1-caught  0
  set leader ""
  set leader-caught 0
  set bugs-in-a-batch 10        ;; ten bugs must be caught to make a batch
  set caught-in-current-batch 0 ;; no bugs are currently caught in the first batch
  set interval-length 0         ;; previous interval-length value is 0 by default
  set batches 0                 ;; no batches caught yet
  set time 0
  set histogram-interval-size 1
  set old-color-map speed-color-map   ;; holds the starting value of the chooser
  ask patches [ set pcolor white ]   ;; white background
  make-initial-bugs
  ask players [ initialize-player ]
  update-plots
end 

to make-initial-bugs
   ask bugs [die]
  create-bugs initial-bugs-each-speed [ set speed 1 ]
  create-bugs initial-bugs-each-speed [ set speed 2 ]
  create-bugs initial-bugs-each-speed [ set speed 3 ]
  create-bugs initial-bugs-each-speed [ set speed 4 ]
  create-bugs initial-bugs-each-speed [ set speed 5 ]
  create-bugs initial-bugs-each-speed [ set speed 6 ]

  ask bugs [
    set shape "bug"
    setxy random-xcor random-ycor
  ]
  ask bugs [ set-color ]
end 
;;;;;;;;;;;;;;;;;;;;;
;; Runtime Procedures
;;;;;;;;;;;;;;;;;;;;;

to go
  every 0.04 [
    listen-clients 
    move-bugs
    ask bugs [set-color]
     ;; advance the clock
    tick
    if ticks mod 10 = 0 [ update-plots ]
  ]
end 

to move-bugs
  ;; the speed factor is a scaling number used to adjust the amount all the bugs move
  ;; for example a speed-factor of 2, scales the speed of all the bugs so they are moving twice as fast
  ;; it is a useful slider to change for slower and faster computers, that might have the bugs
  ;; as a whole population moving too fast or too slow across the screen
  ask bugs [ fd (speed * 0.06) ]
end 
;; keep a stable population of bugs as predation rates go up or down

to check-caught
  ;; extract the coords from the hubnet message
  let clicked-xcor  (item 0 hubnet-message)
  let clicked-ycor  (item 1 hubnet-message)
  ask players with [ user-name = hubnet-message-source ] [
    set xcor clicked-xcor set ycor clicked-ycor      ;; go to the location of the click
    set attempts attempts + 1                        ;; each mouse click is recorded as as an attempt
                                                     ;; for that player
    ;;  if the players clicks close enough to a bug's location, they catch it
    ;;  the in-radius (bug-size / 2) calculation helps make sure the user catches the bug
    ;;  if they click within one shape radius (approximately since the shape of the bug isn't
    ;;  a perfect circle, even if the size of the bug is other than 1)
    
    
    if any? bugs in-radius (bug-size / 2)
    [
      let doomed-bug one-of bugs in-radius (bug-size / 2)
      let speed-of-caught 0
      ask doomed-bug [set speed-of-caught speed
        if (speed-of-caught = 6) [ set total-speed-6-caught (total-speed-6-caught + 1) ]
        if (speed-of-caught = 5) [ set total-speed-5-caught (total-speed-5-caught + 1) ]
        if (speed-of-caught = 4) [ set total-speed-4-caught (total-speed-4-caught + 1) ]
        if (speed-of-caught = 3) [ set total-speed-3-caught (total-speed-3-caught + 1) ]
        if (speed-of-caught = 2) [ set total-speed-2-caught (total-speed-2-caught + 1) ]
        if (speed-of-caught = 1) [ set total-speed-1-caught (total-speed-1-caught + 1) ]
        die
      ]
      set caught caught + 1
      set total-caught total-caught + 1
      
     ;; replace the eaten bug with a random offspring from the remaining population
      ask one-of bugs [ hatch 1 [ rt random 360 ] ]    ]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;
;; Visualization Procedures
;;;;;;;;;;;;;;;;;;;;;

to set-color ;; turtle procedure
  if speed-color-map = "all green"
    [ set color green ]
  if speed-color-map = "violet shades"
    [ set color violet - 4 + speed ]
  if speed-color-map = "rainbow"
    [ set color item (speed - 1) [violet blue green brown orange red] ]
end 

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

to add-player
  set number-players number-players + 1
  create-players 1 [
    set user-name hubnet-message-source
    initialize-player
  ]
end 

to initialize-player
  set attempts 0
  set caught 0
  set hidden? true
  set-percent
  send-student-info
end 

to remove-player
  set number-players (number-players - 1)
  ask players with [ user-name = hubnet-message-source ]
    [ die ]
end 

to set-percent
  ifelse leader-caught > 0
  [ set percent ((caught / leader-caught) * 100)]
  [ set percent 0 ]
end 

to send-student-info
  hubnet-send user-name  "Your name" user-name
  hubnet-send user-name "You have caught" caught
  hubnet-send user-name "# Attempts"  attempts
  hubnet-send user-name "Relative %"  (precision percent 2)
  hubnet-send user-name "Top hunter" leader
  hubnet-send user-name "Top hunter's catches" leader-caught
end 

to listen-clients
  while [hubnet-message-waiting?]
  [
    hubnet-fetch-message
    ifelse hubnet-enter-message?
    [add-player ]
    [
      ifelse hubnet-exit-message?
     [remove-player]
     [
        if ((hubnet-message-tag = "View")  )
         [
            ask players with [ user-name = hubnet-message-source ]
              [ check-caught ]
            update-leader-stats
            ;; update all the players anytime we update the leaders
            ask players
            [
              set-percent
              send-student-info
            ]
         ]
      ]
    ]
  ]
end 

to update-leader-stats
  if any? players
  [
    let leaders players with-max [ caught ]
    let number-leaders count leaders
    ifelse number-leaders > 1
    [ set leader word number-leaders "-way tie" ]
    [ ask one-of leaders [set leader user-name ] ]
    set leader-caught [caught] of one-of leaders
  ]
end 
;;;;;;;;;;;;;;;;;;;;;;
;; Plotting Procedures
;;;;;;;;;;;;;;;;;;;;;;

to update-plots
  set-current-plot "Avg. Bug Speed vs. Time"
   if any? bugs [plotxy time mean [speed] of bugs]
  set-current-plot "Current Bug Population"
  clear-plot
  foreach [1 2 3 4 5 6] [
    set-current-plot-pen word "pen" ?
    plotxy ? count bugs with [speed = ?]
  ]
  ;; creates 6 different histograms of different colors in the same graph
  ;; each histogram is color coded to the color mapping for when the
  ;; SPEED-COLOR-MAP chooser is set to "rainbow" value.
  set-current-plot "Bugs Caught"
  clear-plot
  
  set-histogram-num-bars 8
  set-current-plot-pen "pen1"
  plotxy 1 total-speed-1-caught
  set-histogram-num-bars 8
  set-current-plot-pen "pen2"
  plotxy 2 total-speed-2-caught
  set-histogram-num-bars 8
  set-current-plot-pen "pen3"
  plotxy 3 total-speed-3-caught
  set-histogram-num-bars 8
  set-current-plot-pen "pen4"
  plotxy 4 total-speed-3-caught
  set-histogram-num-bars 8
  set-current-plot-pen "pen5"
  plotxy 5  total-speed-5-caught 
  set-histogram-num-bars 8
  set-current-plot-pen "pen6"
  plotxy 6  total-speed-6-caught
end 

There are 2 versions of this model.

Uploaded by When Description Download
Uri Wilensky almost 9 years ago Bug Hunters Speeds Download this version
Uri Wilensky almost 9 years ago Bug Hunters Speeds Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.