Turtles trapped

No preview image

1 collaborator

Default-person Roha Ali (Author)

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.3 • Viewed 62 times • Downloaded 3 times • Run 0 times
Download the 'Turtles trapped' 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

breed [ RohaAlis RohaAli ]
globals[ name-patch label-patch trapped? turtle-ahead ]

to setup
  clear-all
  ask patches [ set pcolor white]
  setupname
  setup-breeds
  reset-ticks
end 

to setupname
  set name-patch patches with [ pxcor >= 0 and pycor >= 0]
  ask name-patch [
    set pcolor red
  ]
  ask patch 185 87 [
  set label-patch self
  set plabel-color white
  set plabel "ROHA ALI"
  ]
end 

to setup-breeds
  create-RohaAlis 26
  ask RohaAlis [
    setxy -150 + who * 3 random-ycor
    set shape "circle"
    set size 9
    set color green
  ]
end 

to go
  ask RohaAlis
  [
  wander
  wander-in-letters
  ]
    if get-untrapped  = 0 [ stop ]
  tick
end 

to wander
  rt random 20
  lt random 20
  fd 0.6
  if  (any? other RohaAlis-here) [wander]
end 

to wander-in-letters
  set turtle-ahead other patches in-cone 20 5
  if ( pcolor = red )
  [
    set heading towards label-patch
    rt random 20
    lt random 20
    fd 0.62
   set trapped? true
   if ( [pxcor] of patch-ahead 0.1 > 0 ) and  ( trapped? = true )
    ;;if so, reflect heading around x axis
  [ set heading (- heading)
  ]
  ; check: hitting top or bottom wall?
  if ( [pycor] of patch-ahead 0.1 > 0 ) and ( trapped? = true )
    ; if so, reflect heading around y axis
    [ set heading (180 - heading)
  ]
  if pcolor = white [ set trapped? false ]
  ]
end 

to-report get-trapped
  report count RohaAlis with [ pcolor = red ]
end 

to-report get-untrapped
  report count RohaAlis with [ pcolor = white ]
end 

There is only one version of this model, created over 2 years ago by Roha Ali.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.