Simplified Natural Selection Game

Simplified Natural Selection Game preview image

1 collaborator

Default-person Michael Zito (Author)

Tags

biology 

Tagged by Michael Zito about 7 years ago

coevolution 

Tagged by Michael Zito about 7 years ago

education 

Tagged by Michael Zito about 7 years ago

evolution 

Tagged by Michael Zito about 7 years ago

natural selection 

Tagged by Michael Zito about 7 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.1 • Viewed 2033 times • Downloaded 33 times • Run 0 times
Download the 'Simplified Natural Selection Game' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

breed [hawks hawk]
breed [mice mouse]

hawks-own [vision age]
mice-own [camo]

to setup
  ca

  ask patches [
    set pcolor 63 + random 4                  ; its a patchwork world!
    ]

  create-hawks init-hawks [
    set shape "hawk"
    set color 36
    set size .75
    set age 0
    set vision round random-normal init-mean-vision init-SD-vision
    if vision < 0 [set vision 0]              ; keep scores non-negative
    ]

  create-mice init-mice [
    set shape "mouse top"
    set size .2
    set color 32
    set camo round random-normal init-mean-camo init-SD-camo
    if camo < 0 [set camo 0]                  ; keep scores non-negative
    ]

  distribute

  reset-ticks
end 

to go
  if ticks = 30 [stop]
  ask hawks [hunt]
  ask hawks [starve]
  ask mice [evolve-mice?]
  distribute
  tick
end 

to hunt
  if any? mice-here [                         ; if there are mice on this patch
    if vision >= min [camo] of mice-here [    ; and they can be seen
      if-else vision > min [camo] of mice-here
        [evolve-hawks?]                       ; if vision > camo eat and reproduce
        [if random 2 = 0 [evolve-hawks?]]     ; else vision = camo so flip a coin
    ]
  ]
  ; recurse to continue eating until all possible meals eaten
  if any? mice-here and vision >= min [camo] of mice-here [hunt]
end 

to evolve-hawks?
  if-else hawks-coevolve?
    [eat-and-evolve]
    [eat-and-reproduce]
end 

to eat-and-evolve
  ask min-one-of mice-here [camo] [die]  ; eat the mouse
    hatch 1 [                            ; produce an offspring with poorer vision
      set age ticks
      set vision  vision - 1
      if vision < 0 [set vision 0]       ; keep scores non-negative
      ]

    hatch 1 [                            ; produce an offspring with better vision
      set age ticks
      set vision  vision + 1
      ]
  die                                    ; die
end 

to eat-and-reproduce
  ask min-one-of mice-here [camo] [die]  ; eat the mouse
  hatch 2 [                              ; produce 2 offspring with random vision
    set age ticks
    set vision round random-normal init-mean-vision init-SD-vision
    if vision < 0 [set vision 0]         ; keep scores non-negative
    ]
  die                                    ; die
end 

to starve
  if (ticks - age >= 2) [die]            ; if a hawk hasn't eaten in 2 tickss it dies
end 

to evolve-mice?
  if-else mice-coevolve?
    [reproduce-and-evolve]
    [reproduce]
end 

to reproduce-and-evolve
  if not any? other mice-here [          ; if there is no competition
    hatch 1 [                            ; produce an offspring with worse camouflage
        set camo  camo - 1
        if camo < 0 [set camo 0]         ; keep scores non-negative
      ]
    hatch 1 [                            ; produce an offspring with better camouflage
      set camo  camo + 1
      ]

    die                                  ; die
  ]
end 

to reproduce
  if not any? other mice-here [          ; if there is no competition
  hatch 2 [                              ; produce 2 offspring with random camo
    set camo round random-normal init-mean-camo init-SD-camo
    if camo < 0 [set camo 0]             ; keep scores non-negative
    ]
    die                                  ; die
  ]
end 

to distribute
  ask mice [setxy random-xcor random-ycor set heading random 359]
  ask hawks [setxy random-xcor random-ycor set heading random 359]
end 

to reset
  set mice-coevolve? true
  set init-mice 16
  set init-mean-camo 5
  set init-SD-camo 1.5
  set hawks-coevolve? true
  set init-hawks 16
  set init-mean-vision 5
  set init-SD-vision 1.5
end 

There is only one version of this model, created about 7 years ago by Michael Zito.

Attached files

File Type Description Last updated
NatSelGameLab_original.doc word Student Lab about 7 years ago, by Michael Zito Download
Simplified Natural Selection Game.png preview Simplified Natural Selection Game That Runs Better in NetLogo Web about 7 years ago, by Michael Zito Download

This model does not have any ancestors.

This model does not have any descendants.