Mimicry preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)



Tagged by Reuven M. Lerner about 5 years ago


Tagged by Reuven M. Lerner about 5 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 265 times • Downloaded 13 times • Run 0 times
Download the 'Mimicry' modelDownload this modelEmbed this model

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


Batesian mimicry is an evolutionary relationship in which a harmless species (the mimic) has evolved so that it looks very similar to a completely different species that isn't harmless (the model). A classic example of Batesian mimicry is the similar appearance of monarch butterflies and viceroy moths. Monarchs and viceroys are unrelated species that are both colored similarly --- bright orange with black patterns. Their colorations are so similar, in fact, that the two species are virtually indistinguishable from one another.

The classic explanation for this phenomenon is that monarchs taste yucky. Because monarchs eat milkweed, a plant full of toxins, they become essentially inedible to birds. Researchers have documented birds vomiting within minutes of eating monarch butterflies. The birds then remember the experience and avoid brightly colored orange butterfly/moth species. Viceroys, although perfectly edible, avoid predation if they are colored bright orange because birds can't tell the difference.

Recent research now suggests that viceroys might also be unpalatable to bird predators, confusing this elegant explanation. However, we have modeled the relationship anyway. Batesian mimicry occurs in enough other situations (snakes, for example) that the explanation's general truth is unquestionable. The monarch-viceroy story is so accessible --- and historically relevant --- that we believe it to be instructive even if its accuracy is now questioned.


This model simulates the evolution of monarchs and viceroys from distinguishable, differently colored species to indistinguishable mimics and models. At the simulation's beginning there are 450 monarchs and viceroys distributed randomly across the world. The monarchs are all colored red, while the viceroys are all colored blue. They are also distinguishable (to the human observer only) by their shape: the letter "x" represents monarchs while the letter "o" represents viceroys. Seventy-five birds are also randomly distributed across the world.

When the model runs, the birds and butterflies (for the remainder of this description "butterfly" will be used as a general term for monarchs and viceroys, even though viceroys are technically moths) move randomly across the world. When a bird encounters a butterfly it eats the butterfly, unless it has a memory that the butterfly's color is "yucky." If a bird eats a monarch, it acquires a memory of the butterfly's color as yucky.

As butterflies are eaten, they regenerate through asexual reproduction. Each turn, every butterfly must pass two "tests" in order to reproduce. The first test is based on how many butterflies of that species already exist in the world. The carrying capacity of the world for each species is 225. The chances of reproducing are smaller the closer to 225 each population gets. The second test is simply a random test to keep reproduction in check (set to a 4% chance in this model). When a butterfly does reproduce it either creates an offspring identical to itself or it creates a mutant. Mutant offspring are the same species but have a random color between blue and red, but ending in five (e.g. color equals 15, 25, 35, 45, 55, 65, 75, 85, 95, 105). Both monarchs and Viceroys have equal opportunities to reproduce mutants.

Birds can remember up to MEMORY-SIZE yucky colors at a time. The default value is three. If a bird has memories of three yucky colors and it eats a monarch with a new yucky color, the bird "forgets" its oldest memory and replaces it with the new one. Birds also forget yucky colors after a certain amount of time.


Each turn is called a TICK in this model.

The MEMORY-DURATION slider determines how long a bird can remember a color as being yucky. The MEMORY-SIZE slider determines the number of memories a bird can hold in its memory at once.

The MUTATION-RATE slider determines the chances that a butterfly's offspring will be a mutant. Setting the slider to 100 will make every offspring a mutant. Setting the slider to 0 will make no offspring a mutant.

The SETUP button clears the world and randomly distributes the monarchs (all red), viceroys (all blue), and birds. The GO button starts the simulation.

The number of monarchs and viceroys in the world are displayed in monitor as well as the maximum, minimum, and average colors for each type of butterfly.

The plot shows the average color of the monarchs and the average color of the viceroys plotted against time.


Initially, the birds don't have any memory, so both monarchs and viceroys are eaten equally. However, soon the birds "learn" that red is a yucky color and this protects most of the monarchs. As a result, the monarch population makes a comeback toward carrying capacity while the viceroy population continues to decline. Notice also that as reproduction begins to replace eaten butterflies, some of the replacements are mutants and therefore randomly colored.

As the simulation progresses, birds continue to eat mostly butterflies that aren't red. Occasionally, of course, a bird "forgets" that red is yucky, but a forgetful bird is immediately reminded when it eats another red monarch. For the unlucky monarch that did the reminding, being red was no advantage, but every other red butterfly is safe from that bird for a while longer. Monarch (non-red) mutants are therefore apt to be eaten. Notice that throughout the simulation the average color of monarchs continues to be very close to its original value of 15. A few mutant monarchs are always being born with random colors, but they never become dominant, as they and their offspring have a slim chance for survival.

Meanwhile, as the simulation continues, viceroys continue to be eaten, but as enough time passes, the chances are good that some viceroys will give birth to red mutants. These butterflies and their offspring are likely to survive longer because they resemble the red monarchs. With a mutation rate of 5%, it is likely that their offspring will be red too. Soon most of the viceroy population is red. With its protected coloration, the viceroy population will return to carrying capacity.


If the MUTATION-RATE is high, advantageous color genes do not reproduce themselves. Conversely, if MUTATION-RATE is too low, the chances of an advantageous mutant (red) viceroy being born are so slim that it may not happen enough, and the population may go extinct. What is the most ideal setting for the MUTATION-RATE slider so that a stable state emerges most quickly in which there are red monarchs and viceroys co-existing in the world? Why?

If the MEMORY-LENGTH slider is set too low, birds are unable to remember that certain colors are yucky. How low can the MEMORY-LENGTH slider be set so that a stable state of co-existing red monarchs and viceroys emerges?

If you set MUTATION-RATE to 100 and MEMORY to 0, you will soon have two completely randomly colored populations. Once the average color of both species is about 55, return the sliders to MUTATION-RATE equals 16 and MEMORY equals 30 without resetting the model. Does a stable mimicry state emerge? What is the "safe" color?


One very simple extension to this model is to add a RANDOM-COLOR button. This button would give every butterfly in the world a random color. The advantage of red would be gone, but some color (which could be red, or any other color) would eventually emerge as the advantageous color. This models the evolutionary process from an earlier starting place, presumably when even monarchs had different colors.

It would be interesting to see what would happen if birds were made smarter than they are in this model. A smart bird should probably continue to experiment with yucky colors a few times before being "convinced" that all butterflies of that color are indeed distasteful.

You could try to add variables that kept track of how many yucky individuals of the same color a bird ate. Presumably if a bird has eaten several monarchs that are all the same color, it will be especially attentive to avoiding that color as compared to if it had just eaten one butterfly of that color. Making changes of this nature would presumably make the proportion of models and mimics more in keeping with the predictions of theorists that there are generally more models than mimics. In the current model, birds aren't smart enough to learn that most butterflies may be harmless in a given situation.

In a real world situation, the birds would also reproduce. Young birds would not have the experiences necessary to know which colors to avoid. Reproduction of birds, depending on how it happened and how often, might change the dynamics of this model considerably.

One could also refine the mutation-making procedures of the model so that a butterfly is more likely to reproduce a mutant that is only slightly differently colored than to reproduce a mutant that is completely differently colored. In the current model, mutants' colors are simply random.


If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

  • Wilensky, U. (1997). NetLogo Mimicry model. http://ccl.northwestern.edu/netlogo/models/Mimicry. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
  • Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.


Copyright 1997 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.

Comments and Questions

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

Click to Run Model

;; two breeds of butterflies
breed [ monarchs monarch ]
breed [ viceroys viceroy ]

breed [ birds bird ]
birds-own [ memory ]

globals [
  carrying-capacity-monarchs  ;; maximum population of monarchs in the world
  carrying-capacity-viceroys  ;; maximum population of viceroys in the world
  carrying-capacity-birds     ;; maximum population of birds in the world
  color-range-begin           ;; "lowest" color for a butterfly
  color-range-end             ;; "highest" color for a butterfly
  reproduction-chance         ;; The chance and individual has of
                              ;; reproducing (0 - 100) *after*
                              ;; the chance dependent on
                              ;; carrying capacity is evaluated.

;; Setup Procedures

to setup

;; initialize constants

to setup-variables
  set carrying-capacity-monarchs 225
  set carrying-capacity-viceroys 225
  set carrying-capacity-birds 75
  set reproduction-chance 4
  set color-range-begin 15
  set color-range-end 109

;; create 75 birds and 450 butterflies of which half are
;; monarchs and half are viceroys.  Initially, the
;; monarchs are at the bottom of the color range and
;; the viceroys are at the top of the color range.
;; The patches are white for easy viewing.

to setup-turtles
  ask patches [ set pcolor white ]
  set-default-shape monarchs "butterfly monarch"
  set-default-shape viceroys "butterfly viceroy"
  create-birds carrying-capacity-birds
    set color black
    set memory []
    set shape one-of ["bird 1" "bird 2"]
  create-monarchs carrying-capacity-monarchs [ set color red ]
  create-viceroys carrying-capacity-viceroys [ set color blue ]
  ;; scatter all three breeds around the world
  ask turtles [ setxy random-xcor random-ycor ]

;; Runtime Procedures

to go
  ask birds [ birds-move ]
  ;; turtles that are not birds are butterflies
  ask turtles with [breed != birds] [ butterflies-move ]
  ask turtles with [breed != birds] [ butterflies-get-eaten ]
  ask birds [ birds-forget ]
  ask turtles with [breed != birds] [ butterflies-reproduce ]

to birds-move ;; birds procedure
  ;; The birds are animated by alternating shapes
  ifelse shape = "bird 1"
  [ set shape "bird 2"]
  [ set shape "bird 1" ]
  set heading 180 + random 180
  fd 1

to butterflies-move ;; butterflies procedure
  rt random 100
  lt random 100
  fd 1

;; If there is a bird on this patch check the bird's memory
;; to see if this butterfly seems edible based on the color.
;; If the butterfly's color is not in the bird's memory
;; the butterfly dies.  If it's a monarch the bird remembers
;; that its color was yucky

to butterflies-get-eaten  ;; butterfly procedure
  let bird-here one-of birds-here
  if bird-here != nobody
    if not [color-in-memory? [color] of myself] of bird-here
      if breed = monarchs
        [ ask bird-here [ remember-color [color] of myself ] ]

;; helper procedure that determines whether the given
;; color is in a bird's memory

to-report color-in-memory? [c] ;; bird procedure
  foreach memory [ if item 0 ? = c [ report true ] ]
  report false

;; put a color that was yucky in memory

to remember-color [c]  ;; bird procedure
  ;; birds can only remember 3 colors at a time
  ;; so if there are more than 3 in memory we
  ;; need to remove 1 we know that the first item
  ;; in the list will always be the oldest since
  ;; we add items to the back of the list and only
  ;; 1 item can be added per tick
  if length memory >= memory-size
  [ set memory but-first memory ]
  ;; put the new memory on the end of the list
  set memory lput (list c 0) memory

;; birds can only remember for so long, then
;; they forget. They remember colors for MEMORY-LENGTH

to birds-forget ;; bird procedure
  ;; first increment all of the times in memory
  set memory map [list (item 0 ?) (1 + item 1 ?)] memory
  ;; then remove any entries whose times have hit MEMORY-DURATION
  set memory filter [item 1 ? <= MEMORY-DURATION] memory

;; Each butterfly has an equal chance of reproducing
;; depending on how close to carrying capacity the
;; population is.

to butterflies-reproduce ;; butterfly procedure
  ifelse breed = monarchs
  [ if random count monarchs < carrying-capacity-monarchs - count monarchs
     [ hatch-butterfly ] ]
  [ if random count viceroys < carrying-capacity-viceroys - count viceroys
     [ hatch-butterfly ] ]

to hatch-butterfly ;; butterfly procedure
  if random-float 100 < reproduction-chance
    hatch 1
      fd 1
      ;; the chance that the butterfly will
      ;; have a random color is determined by
      ;; the MUTATION slider. select a base-color
      ;; between 15 and 105
      if random-float 100 < mutation-rate
      ;; make a list that contains only the base-color 15-105
      [ set color one-of sublist base-colors 1 10 ]

; Copyright 1997 Uri Wilensky.
; See Info tab for full copyright and license.

There are 15 versions of this model.

Uploaded by When Description Download
Uri Wilensky about 5 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 5 years ago Updated version tag Download this version
Uri Wilensky over 5 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 6 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky about 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 8 years ago Model from NetLogo distribution Download this version
Uri Wilensky about 8 years ago Model from NetLogo distribution Download this version
Uri Wilensky about 8 years ago Mimicry Download this version

Attached files

File Type Description Last updated
Mimicry.png preview Preview for 'Mimicry' over 5 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.