Bug Hunt Speeds and Light

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Model group Stanford-BBA-Spr09 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 4.0.3 • Viewed 427 times • Downloaded 24 times • Run 0 times
Download the 'Bug Hunt Speeds and Light' 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?

This is a 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

You assume the role of a predator amongst a population of bugs. To begin your pursuit of bugs as a predator, 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 "Frequency of bugs" Histogram and the "Number of Bugs vs. Time" graph. 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

INITIAL-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.

THINGS TO NOTICE

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

The 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 1. Slow the model down and watch where new bugs come from when you eat 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 predator 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 predator around the view after the nearest bug.

EXTENDING THE MODEL

Currently the 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). Add a wiggle to the bugs' wandering and make the amount of wiggle inheritable.

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 Camouflage

CREDITS AND REFERENCES

Inspired by EvoDots software:

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

To refer to this model in academic publications, please use: Novak, M. and Wilensky, U. (2005). NetLogo Bug Hunt Speeds model. http://ccl.northwestern.edu/netlogo/models/BugHuntSpeeds. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use: Copyright 2005 Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/BugHuntSpeeds for terms of use.

Comments and Questions

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

Click to Run Model

extensions [gogo]

to setup-gogo
  gogo:open "COM12"
end 


breed [predators predator]
breed [bugs bug]
bugs-own [
  speed    ;; either 1, 2, 3, 4, 5, or 6
]

globals [
  total-speed-1-caught      ;; keeps track of the number of bugs caught with speed of 1
  total-speed-2-caught      ;; keeps track of the number of bugs caught with speed of 2
  total-speed-3-caught      ;; keeps track of the number of bugs caught with speed of 3
  total-speed-4-caught      ;; keeps track of the number of bugs caught with speed of 4
  total-speed-5-caught      ;; keeps track of the number of bugs caught with speed of 5
  total-speed-6-caught      ;; keeps track of the number of bugs caught with speed of 6
]

to setup
  clear-all
  setup-gogo
  set-default-shape bugs "bug"
  set-default-shape predators "bird"
  set-environment
  ask patches [ set pcolor white ]   ;; white background
  foreach [1 2 3 4 5 6] [
    create-bugs initial-bugs-each-speed [ set speed ? ]
  ]
  ask bugs [
    setxy random-xcor random-ycor
    set-color
  ]
  ;; the predator breed contains one turtle that is used to represent
  ;; a predator of the bugs (a bird)
  create-predators 1 [
    set shape "bird"
    set color black
    set size 1.5
    set heading 315
    hide-turtle
  ]
  ;; plot the initial state of the system
  update-plots
end 

to go
  ;; use EVERY to limit the overall speed of the model
  every 0.03 [
    set-environment
    check-caught
    move-predator
    ask bugs [ fd speed * 0.08 ]
    ;; recolor the bugs in case the user changed SPEED-COLOR-MAP
    ask bugs [ set-color ]
    ;; advance the clock
    tick
    ;; plotting takes time, so only plot every 10 ticks
    if ticks mod 10 = 0 [ update-plots ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;
;; Runtime Procedures
;;;;;;;;;;;;;;;;;;;;;

to move-predator
  ask predators [
    setxy mouse-xcor mouse-ycor
    ;; only show the predator if the mouse pointer is
    ;; actually inside the view
    set hidden? not mouse-inside?
  ]
end 

to check-caught
  if not mouse-down? or not mouse-inside? [ stop ]
  let prey [bugs in-radius (size / 2)] of one-of predators
  ;; no prey here? oh well
  if not any? prey [ stop ]
  ;; eat only one of the bugs at the mouse location
  ask one-of prey [
    if speed = 1 [ set total-speed-6-caught total-speed-6-caught + 1 ]
    if speed = 2 [ set total-speed-5-caught total-speed-5-caught + 1 ]
    if speed = 3 [ set total-speed-4-caught total-speed-4-caught + 1 ]
    if speed = 4 [ set total-speed-3-caught total-speed-3-caught + 1 ]
    if speed = 5 [ set total-speed-2-caught total-speed-2-caught + 1 ]
    if speed = 6 [ set total-speed-1-caught total-speed-1-caught + 1 ]
    die
  ]
  ;; replace the eaten bug with a random offspring from the remaining population
  ask one-of bugs [ hatch 1 [ rt random 360 ] ]
end 

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 

;;;;;;;;;;;;;;;;;;;;;;
;; Plotting Procedures
;;;;;;;;;;;;;;;;;;;;;;

;; To avoid having to write out all of the plotting code
;; six times, we use FOREACH to loop over the six possible
;; speeds.

to update-plots
  set-current-plot "Avg. Bug Speed vs. Time"
  plot mean [speed] of bugs

  set-current-plot "Bugs Caught vs. Time"
  foreach [1 2 3 4 5 6] [
    set-current-plot-pen word "speed=" ?
    ;; use RUNRESULT to get the value of the variable with
    ;; the given name
    plotxy ticks runresult (word "total-speed-" ? "-caught")
  ]

  ;; the HISTOGRAM primitive can't make a multi-colored histogram,
  ;; so instead we plot each bar individually
  set-current-plot "Frequency of Bugs"
  clear-plot
  foreach [1 2 3 4 5 6] [
    set-current-plot-pen word "pen" ?
    plotxy ? count bugs with [speed = ?]
  ]

  set-current-plot "Number of Bugs vs. Time"
  foreach [1 2 3 4 5 6] [
    set-current-plot-pen word "speed=" ?
    plot count bugs with [speed = ?]
  ]
end 

to set-environment
  ;; ask patches [set pcolor violet - 4 + environment-color]
  ;; the range of the light sensor is 1-140, I think
  ask patches [set pcolor violet - 4 + ((gogo:sensor 1) * 6 / 140 + 1 ) ]
end 

; *** NetLogo 4.0.3 Model Copyright Notice ***
;
; Copyright 2005 by Uri Wilensky.  All rights reserved.
;
; Permission to use, modify or redistribute this model is hereby granted,
; provided that both of the following requirements are followed:
; a) this copyright notice is included.
; b) this model will not be redistributed for profit without permission
;    from Uri Wilensky.
; Contact Uri Wilensky for appropriate licenses for redistribution for
; profit.
;
; To refer to this model in academic publications, please use:
; Novak, M. and Wilensky, U. (2005). NetLogo Bug Hunt Speeds model.
; http://ccl.northwestern.edu/netlogo/models/BugHuntSpeeds.
; Center for Connected Learning and Computer-Based Modeling,
; Northwestern University, Evanston, IL.
;
; In other publications, please use:
; Copyright 2005 Uri Wilensky.  All rights reserved.
; See http://ccl.northwestern.edu/netlogo/models/BugHuntSpeeds
; for terms of use.
;
; *** End of NetLogo 4.0.3 Model Copyright Notice ***

There is only one version of this model, created over 14 years ago by Rodolphe Courtier.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.