Parental Investment Sexual Conflict

Parental Investment Sexual Conflict preview image

1 collaborator

Default-person César González (Author)

Tags

biology 

Tagged by César González over 6 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.2 • Viewed 329 times • Downloaded 21 times • Run 0 times
Download the 'Parental Investment Sexual Conflict' 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

; Copyright 2018 César González.
; See Info tab for full copyright and license.

;# Breeds
turtles-own [
  ; state
  energy
  age
  nurturing

  ; g-type
  a-nurturing   ; sex-a nurturing time
  b-nurturing   ; sex-b nurturing time
  ;number-eggs  ; number of eggs spawn
  ;egg-size     ; energy provided to each descendent
]

breed [ sex-a a-organism ]
breed [ sex-b b-organism ]

patches-own [
  hatching
]

;# Constants

to-report adult-age report 80 end  ; age when an organism is mature and can reproduce

to-report stride    report 1  end  ; stride length

;# Main functions

to setup
  clear-all
  ; setup the terrain
  ask patches [
    set pcolor green + 1
    set hatching 0
  ]
  ; create the specimens, then initialize their variables
  set-default-shape sex-a "a-shape"
  set-default-shape sex-b "b-shape"
  create-turtles max-population
  ask turtles [
    ; initial state
    random-sex
    set age adult-age
    set size 3
    set energy random max-energy
    set nurturing 0
    setxy random-xcor random-ycor
    ; initial g-type
    set a-nurturing random hatch-age
    set b-nurturing random hatch-age
    ;set number-eggs random initial-number-eggs
    ;set egg-size random initial-egg-size
  ]
  reset-ticks
end 

to go
  ; stop simulation when any sex disappears
  if not any? sex-a or not any? sex-b [ stop ]
  ; control population
  if count turtles > max-population [
    ; above the maximum population the oldest die
    ask max-n-of (count turtles - max-population) turtles [age] [
      die
    ]
  ]
  ; organisms life
  ask turtles [
    be-born
    grow
    reproduce
    and-die
  ]
  ; gardening
  ask patches [
    clean-empty-eggs
  ]
  tick
end 

;# Procedures

to be-born ;.turtle
  ; Darwin says someone has done this for you
end 

to grow ;.turtle
  ; metabolism processes
  metabolise
  ; nurture offspring if any
  nurture
  ; wander around
  move
end 

to metabolise ;.turtle
  ; increase age
  set age age + 1
  ; eat
  set energy energy + 1
  ; change appearance with age
  if age = hatch-age [ set size 1 ]
  if age = adult-age [ set size 3 ]
end 

to nurture ;.turtle
  ; check the adult is nurturing
  if nurturing = 0 [ stop ]
  ; spend energy feeding offspring
  let offspring turtle-set turtles-here with [ size = 0 ]
  set energy energy - (count offspring * nurturing-energy)
  ask offspring [
    set energy energy + nurturing-energy
  ]
  set nurturing nurturing - 1
end 

to move ;.turtle
  ; check mobility
  if age < hatch-age or  ; eggs can't move
     nurturing > 0        ; when nurturing, stay at home
    [ stop ]
  ; take a step in a random direction
  right random-float 50
  left random-float 50
  forward stride
end 

to reproduce ;.turtle
  ; check mating conditions
  if breed = sex-b or    ; avoid duplicated couples
     age < adult-age or  ; adults only
     energy < min-energy-reproduce or  ; a minimum energy is required
     pcolor = white      ; only one egg cluster allowed at a patch
    [ stop ]
  ; find a suitable partner
  let parent-a self
  let parent-b one-of sex-b-here with [ age > adult-age and energy >= min-energy-reproduce ]
  let parents (turtle-set parent-a parent-b)
  if count parents = 2 [
    ; make a nest for the egg cluster
    ask patch-here [
      set pcolor white
      set hatching hatch-age
    ]
    ; spawn eggs and fecundate them
    set energy (energy - number-eggs * egg-size)
    hatch number-eggs [
      ; set initial offspring state
      set energy egg-size
      set age 0
      set size 0
      random-sex
      set nurturing 0
      ; inherit mutated g-type
      set a-nurturing mutate ([ a-nurturing ] of one-of parents)
      set b-nurturing mutate ([ b-nurturing ] of one-of parents)
      ;set number-eggs mutate ([ number-eggs ] of one-of parents) drift
      ;set egg-size mutate ([ egg-size ] of one-of parents) drift
    ]
    ; start nurturing
    ask parent-a [ set nurturing a-nurturing ]
    ask parent-b [ set nurturing b-nurturing ]
  ]
end 

to random-sex ;.turtle
  ifelse random 2 = 0 [
    set breed sex-a
    set color gray
  ] [
    set breed sex-b
    set color orange
  ]
end 

to and-die ;.turtle
  ; when energy reaches zero it's game over
  if energy <= 0 [ die ]
end 

to invasion [ n $a-nurturing $b-nurturing ]
  ; check parameter integrity
  if n < 0 or
     $a-nurturing < 0 or
     $b-nurturing < 0
    [ stop ]
  ; create an invasion of n organisms with given g-type
  create-turtles n [
    set a-nurturing $a-nurturing
    set b-nurturing $b-nurturing
    random-sex
    set color red
    set age adult-age
    set size 3
    set energy random max-energy
    set nurturing 0
    setxy random-xcor random-ycor
  ]
end 

to clean-empty-eggs ;.patch
  if hatching > 0 [ set hatching hatching - 1 ]
  if pcolor = white and hatching = 0 [
    set pcolor green + 1
  ]
end 

;# Reporters

to-report mutate [ gene ] ;.turtle
  let gene' gene + random-float drift - random-float drift
  if gene < 0 [ report 0 ] ; negative values make no sense
  report gene'
end 

There is only one version of this model, created over 6 years ago by César González.

Attached files

File Type Description Last updated
Parental Investment Sexual Conflict.png preview Preview over 6 years ago, by César González Download

This model does not have any ancestors.

This model does not have any descendants.