NetLogo version NetLogo 4.0.4
Running with NetLogoLite.jar version 404.
NetLogo Version: NetLogo 4.0.4
globals [ bumper-color move-speed boundary-width ] turtles-own [ veering? ] to setup ca set bumper-color red - 3 set move-speed .1 set boundary-width 10 ask patches with [ pxcor + boundary-width > max-pxcor or pxcor - boundary-width < min-pxcor or pycor + boundary-width > max-pycor or pycor - boundary-width < min-pycor ] [ set pcolor bumper-color ] ;; ask n-of 100 patches with [ pcolor = black ] ;; [ sprout 1 ;; [ rt random-float 360 ;; set shape "default" ;; set color blue ;; set veering? false ;; ] ;; ] let pop 100 create-turtles 100 [ home set heading who / (pop) * 360 jump 5 set color blue set veering? false ] end to go ask turtles [ ifelse veering? = false [ ifelse inside-edge-boundary [ set color red set veering? true ] [ rt (turn-speed * (1 - random-float 2.0)) ] ] [ ifelse pcolor = bumper-color [ lt turn-speed * subtract-headings heading towardsxy-nowrap 0 0 ] [ set veering? false set color blue ] ] jump move-speed ] tick end to-report inside-edge-boundary report ( ( pcolor = bumper-color ) ) end to-report reflection-angle report towardsxy-nowrap 0 0 end
View or download the complete model file (to download: right-click, save-link-as):
-- Download veer-from-edges --