NetLogo version NetLogo 4.0.4
Running with NetLogoLite.jar version 404.
Summary | In-cone turtle-vision demonstration |
Copyright | 2004,2009 James P Steiner |
NetLogo Version: NetLogo 4.0.4
globals [ food-color shadow-color ground-color eaten-color greeting? ] patches-own [ freshness ;; matched with ticker to indicate freshness of change ] turtles-own [ prior-not-food ] to go ask turtles [ ;; remove greeting text, if present if greeting? != false [ greeting false ] ;; if the turtle is standing on food, eat it if shade-of? food-color pcolor [ set pcolor eaten-color set label label + 1 ] ;; initialize visi-cone let visi-cone 0 ;; get patches in vision--two versions, one with no-wrap, one without no-wrap ifelse no-wrap? [ set visi-cone patches in-cone-nowrap (world-width * vision-range) vision-width ] [ set visi-cone patches in-cone (world-width * vision-range) vision-width ] ;; food are visible patches that are the food color let food visi-cone with [ shade-of? food-color pcolor ] ;; not-food are visible patches that are the ground color let not-food visi-cone with [ shade-of? ground-color pcolor ] ;; (neither of the above contains any eaten patches) ;; change color to show range of in-cone ;; mark for later erasing of the shadow ask not-food [ set pcolor shadow-color set freshness ticks ] ;; previously visible patches with a stale marker are changed back ask prior-not-food with [ freshness != ticks ] [ set pcolor ground-color ] ;; (this is to improve speed of shadow drawing, vs. resetting color ;; of ALL patches, or even of all prviously shadowed patches if not is-patch? patch-ahead 1 [ rt 175 + random-float 10 ] ifelse any? food [ set color orange ;; indicates food in sight jump speed ;; move forward, maybe towards the food ] [ set color violet ;; indicates no food visible rt 15 - random 30 ;; change heading.. hope to find some food jump .1 * speed ;; move forward, slowly ] ;; store the set of visible not-food (for erasing on next pass set prior-not-food not-food ;; some food grows back if random 300 = 1 [ let eaten patches with [ pcolor = eaten-color ] if any? eaten [ ask one-of eaten [ set pcolor food-color ] ] ] ] ;; increment freshness ticker tick end to setup ca set food-color lime set eaten-color yellow - 3 ;; can be ANY color besides food or ground shades set ground-color black set shadow-color gray ;; MUST be shade of ground-color crt 1 [ set size 5 set color white set label 0 set shape "seeker" set prior-not-food (patches with [ false ]) ] ask patches [ if random 100 < 5 [ set pcolor food-color ] ] greeting true end to startup setup end to greeting [ show? ] ifelse show? [ set greeting? true ask patch max-pxcor (max-pycor - 1) [ set plabel "Click GO to begin animation" ] ] [ set greeting? false ask patch max-pxcor (max-pycor - 1) [ set plabel "" ] ] end
View or download the complete model file (to download: right-click, save-link-as):
-- Download food-seeker_2009 --