Fish Predator Prey Interaction Model

Fish Predator Prey Interaction Model preview image

1 collaborator

Default-person Ian Kenny (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 269 times • Downloaded 27 times • Run 0 times
Download the 'Fish Predator Prey Interaction Model' modelDownload this modelEmbed this model

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


Fish Predator-Prey Model ODD Description

This file describes a model which simulates typical fish movement and simple bioenergetics. The file uses the markup language used by NetLogo's Info tab starting with NetLogo version 5.0.

Purpose

This model was designed to simulate typical fish movement patterns as well as to show predator-prey cycles in the presence of fluctuating chlorophyll-a levels (a proxy for phytoplankton biomass). The purpose of this model is to educate scientists and non-scientists about fish movement dynamics, how population levels can fluctuate under different input conditions, and how predator-prey cycles can develop.

Entities, State Variables, and Scales

The model has three kinds of entities: prey agents, predator agents, and square patches of plankton. The patches make up a square grid landscape of 200 × 200 patches, and each patch has a state variable for chlorophyll-a density. Predators and prey are primarily characterized by their energy, an integer state variable and their location, but they additionally have agentsets for other nearby prey and predators. It is not specified in the model, but one patch should correspond to 1 square meter in the real world. A patchy distribution of chl-a at this scale is not representative of the real world. Simulations last indefinitely and the length of one time step isn’t specified but is approximately 1 minute.

Process Overview and Scheduling

Each time step, prey and predators move forward one patch. They also update their agentset variable and react accordingly as described in the procedures section. The order in which turtles execute their code is random. Additionally, predator energy decreases by 0.6 each tick and prey energy decreases by 0.2 each tick to create realistic predator-prey cycles. The user can specify the time step between chl-a bloom occurrences. Chl-a values are visually updated every 25 ticks to reduce CPU load.

Design Concepts and Procedures

The important parameters of this model are the fluctuations in predator-prey biomass, and the change in the spatial distribution of predators, prey, and chl-a values over time. Total chl-a and prey and predator populations are visualized in a graph that updates each tick.

Patch chl-a blooms occur after a set number of ticks determined by the user. Chl-a values can not increase past 10 mg/m^3 per patch, a typical carrying capacity for phytoplankton. Every 25 ticks, if chl-a has fallen below 0.4 for a patch, the chl-a for said patch will be reduced to 0 to constrain phytoplankton growth.

Sensing is incredibly important in this model because prey and predators use the user-determined variable ‘vision’ to influence all of their decisions. Vision determines the radius of patches that turtles can see other turtles around them.

Every tick, if prey or predator energy has fallen below 0 they will die. If energy is above 300, they will spawn a new turtle of their species with 100 energy, and lose 100 energy. If a prey has no predators within its vision and is on a patch with chl-a above 1, it will add half of the patch’s chl-a value to its energy and decrease the patch’s chl by half. If a predator eats a prey, it will gain 50 energy. 8% of the time, turtles will turn in a random direction rather than doing the adaptive behavior to account for random movement in fish.

If a prey senses predator(s) within its vision, it will turn away from the nearest predator and move forward by vision / 3. If there are no predators and no food within a radius of 3, then the prey will school with other prey. If a predator senses prey within its vision, it will turn towards the nearest prey, move forward by vision / 2, and initiate an attack. Otherwise, predators will school with other predators for more efficient hunting. Predators can only attack every 15 ticks.

Initialization

The environment is initialized through two user controlled variables: food-clusters, which determines the number of chl-a clusters, and food-cluster-size, which determines the size of each chl-a cluster. Number of initial prey and predators are determined by the user. Prey and Predators locations are initialized randomly throughout the grid. They are initialized with 299 energy.

Submodels

Chl-a blooms are created by adding the mean chl of each patch’s neighboring patches to its own chl. Each tick, prey must add all other turtles within its vision to either the agentset schoolmates if it is another prey, or the agentset attackers if it is a predator. Predators must add all other turtles within its vision to either the agentset schoolmates if it is another predator, or the agentset targets if it is a prey. If there are attackers or targets, predators and prey will either turn away from or towards the nearest attacker or target. If turtles school, they will either turn away from their nearest schoolmate if they are too close to them, or otherwise turn towards the average schoolmate heading. If predators cannot attack because they are on cooldown, they will follow the average target heading of targets within their vision. When turtles are turning towards or away from something, they cannot turn at a greater degree than their max turn radius(5).

Comments and Questions

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

Click to Run Model

globals
[
  patch-counter1 ;counter for setting patch color
  patch-counter2 ;counter for growing patches
]

breed[prey a-prey] ;create prey breed
breed[predators predator] ;create predator breed

patches-own
[
  chl ;chl(mg/m^3) = Chlorophyl-A, a commonly used proxy for phytoplankton biomass
]
turtles-own
[
  energy
  schoolmates ;agentset of nearby fish of the same species
  nearest-neighbor ;closest schoolmate
  targets ;agentset of potential targets for predators
  nearest-target ;closest target for predators
  attackers ;agentset of potential predators
  nearest-attacker ;closest predator to a prey fish
  attack-counter ;counter for whether a predator can attack or not
]

to setup
  ca
  reset-ticks

  ask n-of food-clusters patches ;chl patch sizes are determined by the user
  [
    ifelse food-cluster-size > 20 ;if food-cluster-size is set too small, it will cause an error when the radius is set to food-cluster-size/5
    [
      ask n-of food-cluster-size patches in-radius (food-cluster-size / 5)
      [
        set chl 10
      ]
    ]
    [
      ask n-of food-cluster-size patches in-radius (food-cluster-size / 4)
      [
        set chl 10
      ]
    ]
  ]

  ask patches ;chl values are set in steps and are based upon the chl values of their neighbors, creating a realistic distribution of values
  [
    if chl = 0 and [chl = 10] of one-of neighbors
    [
      set chl 7
    ]
  ]

  ask patches
  [
    if chl = 0 and [chl >= 7] of one-of neighbors
    [
      set chl 4
    ]
  ]

  ask patches
  [
    if chl = 0 and [chl >= 4] of one-of neighbors
    [
      set chl 2
    ]
  ]

  ask patches
  [
    set pcolor scale-color green chl 18 0
    set patch-counter1 25
    set patch-counter2 bloom-time-interval

    if chl = 0
    [
      set pcolor sky
    ]
  ]


  create-prey initial-num-prey-fish ;initialize prey fish
  [
    set size 3
    set color orange
    setxy random-xcor random-ycor
    set schoolmates no-turtles
    set energy 299

    ifelse fish?
    [set shape "fish"]
    [set shape "default"]
  ]

  create-predators initial-num-predator-fish ;initialize predator fish
  [
    set size 5
    set color red
    setxy random-xcor random-ycor
    set schoolmates no-turtles
    set energy 299

    ifelse fish?
    [set shape "fish"]
    [set shape "default"]
  ]
end 

to go
  ask patches
  [
    set patch-counter1 patch-counter1 - 1
    set patch-counter2 patch-counter2 - 1

    if patch-counter2 <= 0
    [
      if chl <= 10 and [chl > 0] of one-of neighbors
      [
        set chl chl + mean [chl] of neighbors ;creates a large chl (phytoplankton) bloom
      ]

      if chl > 10
      [
        set chl 10
      ]

      set patch-counter2 bloom-time-interval
    ]

    if patch-counter1 <= 0 ;updates the map with new chl values
    [
      set pcolor scale-color green chl 18 0

      if chl >= 0 and chl < 0.4
      [
        set pcolor sky
        set chl 0
      ]

      set patch-counter1 25
    ]
  ]

  ask prey
  [
    prey-move
  ]

  ask predators
  [
    predator-move
  ]

  ask turtles
  [
    forward 1
  ]

  tick
end 

to prey-move
  set schoolmates other prey in-radius vision
  set attackers other predators in-radius vision
  set energy energy - 0.2

  if energy < 0
  [
    ask self [die]
  ]

  if energy > 300 ;energy needed to reproduce
  [
    hatch 1
    [
      set schoolmates no-turtles
      set attackers no-turtles
      set energy 100
    ]

    set energy energy - 100 ;reproduction cost
  ]

  ifelse random-float 1 < 0.08 ;random movement
  [
    right (random 50) - 25
  ]
  [
    ifelse any? attackers
    [
      set nearest-attacker min-one-of attackers [distance myself]

      turn-towards (atan [dx] of nearest-attacker [dy] of nearest-attacker) 30 ;prey evasive movement

      if vision > 0
      [
        forward vision / 3
      ]
    ]
    [
      if any? patches with [chl > 1] in-radius 3 ;prey eat phytoplankton
      [
        let food max-one-of patches in-radius 3 [chl]

        turn-towards (towards food) prey-food-affinity

        set energy energy + (chl / 2)
        set chl chl / 2
      ]

      if any? schoolmates
      [
        set nearest-neighbor min-one-of schoolmates [distance myself]

        ifelse distance nearest-neighbor < 1
        [
          turn-away ([heading] of nearest-neighbor) 5 ;separates itself from neighbors if too close
        ]
        [
          turn-towards average-schoolmate-heading 5 ;changes directions to align with neighbors headings to exhibit grouping behavior
        ]
      ]
    ]
  ]
end 

to predator-move
  set schoolmates other predators in-radius vision
  set targets other prey in-radius vision

  set attack-counter attack-counter - 1
  set energy energy - 0.6

  if energy < 0
  [
    ask self [die]
  ]

  if energy > 300 ;energy needed to reproduce
  [
    hatch 1
    [
      set schoolmates no-turtles
      set targets no-turtles
      set energy 100
    ]

    set energy energy - 100 ;reproduction cost
  ]

  ifelse random-float 1 < 0.08 ;random movement
  [
    right (random 50) - 25
  ]
  [
    ifelse any? targets
    [
      set nearest-target min-one-of targets [distance myself]

      ifelse attack-counter <= 0
      [
        turn-away (atan [dx] of nearest-target [dy] of nearest-target) 30 ;predator attack movement

        if vision > 0
        [
          forward vision / 2
        ]

        if random-float 1 < attack-success-rate ;attacks are successful half of the time
        [
          ask nearest-target [die]
          set energy energy + 60
        ]

        set attack-counter 15 ;predators will only attack after a given interval, creating a realistic attack pattern
      ]
      [
        turn-away average-target-heading 20 ;predators will follow their targets
      ]
    ]
    [
      if any? schoolmates ;if predators have no targets, they will school to hunt more efficiently
      [
        set nearest-neighbor min-one-of schoolmates [distance myself]

        ifelse distance nearest-neighbor < 1
        [
          turn-away ([heading] of nearest-neighbor) 5 ;separates itself from neighbors if too close
        ]
        [
          turn-towards average-schoolmate-heading 5
        ]
      ]
    ]
  ]
end 



;Helper functions

to turn-towards [new-heading max-turn-radius] ;turns towards something by subtracting current and new headings
  let turn subtract-headings new-heading heading

  ifelse abs turn > max-turn-radius
  [
    ifelse turn > 0
    [
      right max-turn-radius
    ]
    [
      left max-turn-radius
    ]
  ]
  [
    ifelse turn > 0
    [
      right turn
    ]
    [
      left turn
    ]
  ]
end 

to turn-away [new-heading max-turn-radius] ;turns away from something by subtracting current and new headings
  let turn subtract-headings heading new-heading

  ifelse abs turn > max-turn-radius
  [
    ifelse turn > 0
    [
      right max-turn-radius
    ]
    [
      left max-turn-radius
    ]
  ]
  [
    ifelse turn > 0
    [
      right turn
    ]
    [
      left turn
    ]
  ]
end 

to-report average-schoolmate-heading  ;Cannot simply average heading values (ie. avg of 1 and 359 should be calculated as 0)
  let x-component sum [dx] of schoolmates
  let y-component sum [dy] of schoolmates
  ifelse x-component = 0 and y-component = 0
  [
    report heading
  ]
  [
    report atan x-component y-component
  ]
end 

to-report average-target-heading  ;Cannot simply average heading values (ie. avg of 1 and 359 should be calculated as 0)
  let x-component sum [dx] of targets
  let y-component sum [dy] of targets
  ifelse x-component = 0 and y-component = 0
  [
    report heading
  ]
  [
    report atan x-component y-component
  ]
end 

There is only one version of this model, created over 1 year ago by Ian Kenny.

Attached files

File Type Description Last updated
Fish Predator Prey Interaction Model.png preview Preview for 'Fish Predator Prey Interaction Model' over 1 year ago, by Ian Kenny Download

This model does not have any ancestors.

This model does not have any descendants.