Cyberslug 2.0

Cyberslug 2.0 preview image

2 collaborators

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.1 • Viewed 169 times • Downloaded 14 times • Run 0 times
Download the 'Cyberslug 2.0' 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

;;CYBERSLUG

;;Create animats and assign qualities

breed [Cslugs Cslug]
breed [probos proboscis]
breed [flabs flab]
breed [hermis hermi]
breed [fauxflabs fauxflab]
probos-own [parent phase]
Cslugs-own [sns_hermi Reward Reward_neg App_State_Switch sns_flab_left sns_flab_right sns_hermi_left sns_hermi_right sns_betaine_left sns_betaine_right speed turn-angle Nutrition Satiation
 App_State Incentive Somatic_Map Vf Vh alpha_hermi beta_hermi lambda_hermi alpha_flab beta_flab lambda_flab delta_Vh delta_Vf hermcount flabcount
fauxflabcount]
patches-own [odor_flab odor_hermi odor_betaine]

to startup
  setup
end 

to setup
  clear-all

  create-Cslugs 1 [
    set shape "Cslug"
    set color orange - 2
    set size 16
    set heading 0

    set Nutrition 0.5
    set Incentive 0
    set Somatic_Map 0
    set Satiation 0.5

;Preliminary Rescorla-Wagner parameters for learning Hermi & Flab odors. V is learned value of an odor, alpha is the salience
;(or noticeability) of an odor, beta is the learning rate, and lambda sets the maximum value of learning (between 0 and 1).
    set Vf 0
    set Vh 0
    set alpha_hermi 0.5
    set beta_hermi 1
    set lambda_hermi 1
    set alpha_flab 0.5
    set beta_flab 1
    set lambda_flab 1

;Give Cslug a feeding apparatus for decorative effect
    hatch-probos 1 [
      set shape "airplane"
      set size size / 2
      set parent myself
    ]

; Track Cslug's path
    pen-down
  ]

 create-flabs flab-populate [
    set shape "circle"
    set size 1
    set color red + 2
    setxy random-xcor random-ycor
  ]

  create-hermis hermi-populate [
    set shape "circle"
    set size 1
    set color green + 2
    setxy random-xcor random-ycor
  ]

    create-fauxflabs fauxflab-populate [
    set shape "circle"
    set size 1
    set color blue
    setxy random-xcor random-ycor
  ]

    reset-ticks
end 

to go

;; allow user to drag things around
  if mouse-down? [
    ask Cslugs [
      if distancexy mouse-xcor mouse-ycor < 3 [setxy mouse-xcor mouse-ycor]
    ]
    ask flabs [
      if distancexy mouse-xcor mouse-ycor < 3 [setxy mouse-xcor mouse-ycor]
    ]
    ask hermis [
      if distancexy mouse-xcor mouse-ycor < 3 [setxy mouse-xcor mouse-ycor]
    ]
  ]

; Initialize, deposit, diffuse, and evaporate odors
  ask hermis [set odor_hermi 0.5]
  ask hermis [set odor_betaine 0.5]
  ask flabs [set odor_flab 0.5]
  ask flabs [set odor_betaine 0.5]
  ask fauxflabs [set odor_flab 0.5]
  ask fauxflabs [set odor_betaine 0.5]

;; diffuse odors
  diffuse odor_hermi 0.5
  diffuse odor_flab 0.5
  diffuse odor_betaine 0.5

;; evaporate odors
  ask patches [
    set odor_hermi 0.95 * odor_hermi
    set odor_flab 0.95 * odor_flab ; changed from 0.98 to 0.95
    set odor_betaine 0.95 * odor_betaine
    recolor-patches
  ]

;; Cslug actions

  ask Cslugs [

    update-sensors
    update-proboscis
    set speed 0.06
    set turn-angle -1 + random-float 2


    ;; Detecting prey
    set sns_hermi (sns_hermi_left + sns_hermi_right ) / 2
    let sns_betaine (sns_betaine_left + sns_betaine_right) / 2
    let sns_flab (sns_flab_left + sns_flab_right ) / 2
    let H (sns_hermi - sns_flab)
    let F (sns_flab - sns_hermi)

    set Reward sns_betaine / (1 + (0.5 * Vh * sns_hermi) ) + 1.32 * Vh * sns_hermi ; R
    set Reward_neg 1.32 * Vf * sns_flab ; R-



    set Nutrition Nutrition - 0.0005 * Nutrition ; Nutritional state declines with time
    set Satiation 1 / ((1 + 0.7 * exp(-4 * Nutrition + 2)) ^ (2))
    set Incentive Reward - Reward_neg;
    set Somatic_Map (- ((sns_flab_left - sns_flab_right) / (1 + exp (-50 * F)) + (sns_hermi_left - sns_hermi_right) / (1 + exp (-50 * H))))
    set App_State 0.01 + (1 / (1 + exp(- (Incentive * 0.6) + 10 * satiation)) + 0.1 * ((App_State_Switch - 1) * 0.5)); + 0.25
    set App_State_Switch (((-2 / (1 + exp(-100 * (App_State - 0.245)))) + 1)) ; The switch for approach-avoidance

    set turn-angle (2 * App_State_Switch) / (1 + exp (3 * Somatic_Map)) - App_State_Switch

    set speed 0.1

    rt turn-angle
    fd speed

;; PREY CONSUMPTION AND ODOR LEARNING

    let hermitarget other (turtle-set hermis) in-cone (0.4 * size) 45
    if any? hermitarget [
      set Nutrition Nutrition + count hermitarget * 0.3
      set hermcount hermcount + 1
      ask hermitarget [setxy random-xcor random-ycor]
      set delta_Vh alpha_hermi * beta_hermi * (lambda_hermi - Vh)
      set Vh Vh + delta_Vh ; The Rescorla-Wagner Learning Algorithm
    ]

    let flabtarget other (turtle-set flabs) in-cone (0.4 * size) 45
    if any? flabtarget [
      set Nutrition Nutrition + count flabtarget * 0.3;
      set flabcount flabcount + 1
      ask flabtarget [setxy random-xcor random-ycor]
      set delta_Vf alpha_flab * beta_flab * (lambda_flab - Vf)
      set Vf Vf + delta_Vf ; The Rescorla-Wagner Learning Algorithm
    ]

    let fauxflabtarget other (turtle-set fauxflabs) in-cone (0.4 * size) 45
    if any? fauxflabtarget [
      set Nutrition Nutrition + count fauxflabtarget * 0.3
      set fauxflabcount fauxflabcount + 1
      ask fauxflabtarget [setxy random-xcor random-ycor]

      set delta_Vf alpha_flab * beta_flab * (0 - Vf)
      set Vf Vf + delta_Vf; Odor_flab is linked to Reward, a virtual extinction mechanism
    ]

  ]


;; Hermi and Flab actions

  ask flabs [
    rt -1 + random-float 2
    fd 0.02
  ]

  ask hermis [
    rt -1 + random-float 2
    fd 0.02
  ]

  ask fauxflabs [
    rt -1 + random-float 2
    fd 0.02
  ]


  tick
  if ticks = 150000 [stop] ; definitie end of an epoch of play
end 

to update-proboscis
 ask probos [
    set heading [heading] of parent
    setxy ([xcor] of parent) ([ycor] of parent)
    ifelse ([sns_betaine_left] of parent > 5.5) or ([sns_betaine_right] of parent > 5.5)
      [set phase (phase + 1) mod 20]
      [set phase 0]
    fd (0.15 * size) + (0.1 * phase)
  ]
end 

to update-sensors

  let odor_flab_left [odor_flab] of patch-left-and-ahead 40 (0.4 * size)
  ifelse odor_flab_left > 1e-7
    [set sns_flab_left 7 + (log odor_flab_left 10)]
    [set sns_flab_left 0]

  let odor_flab_right [odor_flab] of patch-right-and-ahead 40 (0.4 * size)
  ifelse odor_flab_right > 1e-7
    [set sns_flab_right 7 + (log odor_flab_right 10)]
    [set sns_flab_right 0]

  let odor_hermi_left [odor_hermi] of patch-left-and-ahead 40 (0.4 * size)
  ifelse odor_hermi_left > 1e-7
    [set sns_hermi_left 7 + (log odor_hermi_left 10)]
    [set sns_hermi_left 0]

  let odor_hermi_right [odor_hermi] of patch-right-and-ahead 40 (0.4 * size)
  ifelse odor_hermi_right > 1e-7
    [set sns_hermi_right 7 + (log odor_hermi_right 10)]
    [set sns_hermi_right 0]

  let odor_betaine_left [odor_betaine] of patch-left-and-ahead 40 (0.4 * size)
  ifelse odor_betaine_left > 1e-7
    [set sns_betaine_left 7 + (log odor_betaine_left 10)]
    [set sns_betaine_left 0]

  let odor_betaine_right [odor_betaine] of patch-right-and-ahead 40 (0.4 * size)
  ifelse odor_betaine_right > 1e-7
    [set sns_betaine_right 7 + (log odor_betaine_right 10)]
    [set sns_betaine_right 0]
end 

to recolor-patches
    ifelse odor_flab > odor_hermi [
      set pcolor scale-color red odor_flab 0 1
    ][
      set pcolor scale-color green odor_hermi 0 1
    ]
end 

to show-sensors
  ask Cslugs [
    ask patch-left-and-ahead 40 (0.4 * size) [set pcolor yellow]
    ask patch-right-and-ahead 40 (0.4 * size) [set pcolor yellow]
  ]
end 

There is only one version of this model, created almost 6 years ago by Rhanor Gillette.

Attached files

File Type Description Last updated
Cslug.pdf pdf Implementing Goal-Directed Foraging Decisions of a Simpler Nervous System in Simulation almost 6 years ago, by Rhanor Gillette Download
Cyberslug 2.0.png preview Preview for 'Cyberslug 2.0' almost 6 years ago, by Rhanor Gillette Download

This model does not have any ancestors.

This model does not have any descendants.