thigmotaxis

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 111 times • Downloaded 7 times • Run 0 times
Download the 'thigmotaxis' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; setup breeds ;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;


breed [ predators predator ]
breed [markers marker] ; silent breed marking obstacles ahead

globals
[
  thigmo-patch-threshold ; patch value at which random walks become directed towards attractive patches
  pred-v ;; predator foraging velocity
  random-walk ;;;; the lt or rt amount in degrees
  expt-time
]

predators-own  [
                 last-head ; the last heading of the predator before surveying an area for prey or obstacles. Prevents repeated wall bouncing with inacessible prey.
                 last-turn ; l or r
                 pred-d-ob ;; distance to nearest ob
                 pred-ob-n ;; number of obstacle neighbours
               ]

patches-own [ob ; whether or not a patch is an obstacle
             dist-ob ; distance to closest obstacle
             thig-zone ;;; boundary patches between obstacle and non obstacle patches
             thigmo] ;; how attractive non obstacle patches are to prey and/or predators based on mean proximity to obstacles


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; setup predator, prey and habitat ;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  reset-ticks
  set thigmo-patch-threshold 0
  set pred-v 3 ;; v in patches per second
  set random-walk 50 ;;;



  ask patches with [pxcor > 29 and pxcor < 70  and
                     pycor = 50 ]
    [ set pcolor blue ]

  ask patches with [pycor > 29 and pycor < 70 and
                     pxcor = 50 ]
    [ set pcolor blue ]


  ask patches with [pcolor = blue] ; assign obstacle vals of 1
  [set ob 1]


  ;;;;;; distance to obstacles for thigmotactic movement

  ask patches with [ob = 0] [set dist-ob distance min-one-of patches with [ob = 1] [distance myself]]

  ask patches with [ob = 0] [calc-thigmo
  set pcolor scale-color black thigmo 1 0
  ]

  ;;;; set boundary around obstacles

  ask patches with [any? neighbors with [ob = 1] and pcolor != blue]
    [set pcolor yellow
     set thig-zone 1]






  set expt-time 0 ;; time in s for each trial
  ;;
  set-default-shape markers "dot"

 ask n-of 1 patches with [ob = 0]
    [
    sprout-predators 1 [
    set shape "default"
    set color red
    set size 5]
    ]


    ask predators [
    set last-turn "r"
    set pred-ob-n count neighbors with [ob = 1]
    set pred-d-ob distance min-one-of patches with [ob = 1] [distance myself]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; GO PROCEDURE ;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
  ask markers [ die ]
  keep-time
  if expt-time > 1000 ;; reset trials at the end of trial period
  [;set prey-den prey-den + 1 ; increase prey density by one after each period
   set expt-time 0 ;; reset time
   ask predators [die] ; remove predators from previous trial
   set thigmo-patch-threshold thigmo-patch-threshold + 0.05
   refresh-predators ;; create new predators and prey for the new trial at next prey density

  ]

   ask predators [
    move
    set pred-ob-n count neighbors with [ob = 1]
    set pred-d-ob distance min-one-of patches with [ob = 1] [distance myself]
  ]

  tick
  if thigmo-patch-threshold > 0.85 [stop]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; obstacle and prey detection procedures ;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to mlos-ob  ;; marker procedure FOR OBSTACLES
  let dist 0
  let last-patch patch-here
  ;; iterate through all the patches
  ;; starting at the patch directly ahead
  ;; going through MAXIMUM-VISIBILITY
  while [dist <= pred-v] [  ;; not react-D but move distance
    let p patch-ahead dist
    if p != last-patch and [ob] of p = 1 [
      ask p [ sprout-markers 1 [ set color green
      set size 2 ] ]
      set last-patch p
    ]
    set dist dist + 0.5

  ]
end 

to sweep-area  ; for obstacles

       let lrot 1
       let rrot 1
       set last-head heading
  while [lrot <= random-walk or rrot <= random-walk]
        [
        ifelse last-turn = "r" ;; predators-own last turn for this, setup as r initially
         [rt rrot ;;; turn 1 degree initially
          mlos-ob; check for markers at the new ahead
          set heading last-head ;; face ahead again
          set rrot rrot + 1 ;;  add 1 to right turn
          set last-turn "l" ;; setup to check left in the while loop
         ]

         [lt lrot
          mlos-ob
          set heading last-head ; turn back to straight ahead
          set lrot lrot + 1
          set last-turn "r"
         ]
         ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; detection and movement procedures ;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to move
  ifelse [thig-zone] of patch-here = 0 ;;; if not in the obstacle boundary zone:
    [
     ask markers [die]
     sweep-area
      while [count markers > 0] ;;
             [
              ask markers [die]
              lt random 360
              sweep-area
             ]
     ask markers [die]
     thigmo-walk
    ]
    [
     surface-walk
    ]
end 

to thigmo-walk

  ifelse any? patches in-cone pred-v 100 with [thigmo >= thigmo-patch-threshold]
    [
    face max-one-of patches in-cone pred-v 100 [thigmo]
    fd pred-v
    ]
    [
    lt random random-walk
    rt random random-walk
    fd pred-v
    ]
end 

to surface-walk
  ifelse random 100 > 20 ;; some p that predator will random walk or surface walk
  [
   let hop 0
   while [hop <= pred-v]
    [
     let next-thig-patch min-one-of ob-neighbors [turn-amount]
     face  next-thig-patch
     fd 1
     set hop hop + 1
    ]
  ]
  [
   ask markers [die]
     sweep-area
      while [count markers > 0] ;;
             [
              ask markers [die]
              lt random 360
              sweep-area
             ]
     lt random random-walk
     rt random random-walk
     fd pred-v
  ]
end 





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;  prey capture and handling procedures ;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to refresh-predators
   ask n-of 1 patches with [ob = 0]
    [
    sprout-predators 1 [
    set shape "default"
    set color red
    set size 5]
    ]
   ask predators [
   set last-turn "r"]
end 

to keep-time

  set expt-time expt-time + 1
end 

to calc-thigmo

  ;;; average distance to nearest patch across all non ob neighbours (including each central non ob patch)...then take 1 over that val

  set thigmo 1 / (((( mean [dist-ob] of neighbors with [ob = 0] ) * count neighbors with [ob = 0] ) + dist-ob) / (count neighbors with [ob = 0] + 1))
  ;set thigmo precision thigmo 2 ;; if labelling
end 

to-report ob-neighbors  ;; patch procedure
  ;; report patches that are in the obstacle boundary layer
  report neighbors with [thig-zone = 1]
end 

;; computes the turn the calling turtle would have to make to face this patch

to-report turn-amount  ;; patch procedure
  let this-patch self
  report [subtract-headings (towards this-patch) heading] of myself
end 

There is only one version of this model, created almost 4 years ago by Daniel Barrios-O'Neill.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.