turtles-own[hasFood? ahead left right] ;;turtle-specific variables patches-own[chemlevel isNest? food] ;;patch-specific variables globals [count] ;;global variables to setup ca ;;clear the screen setup-agents setup-patches setcount 0 end to setup-agents ;;create 100 'ants' crt 100 ;;initialize the turtles' color, shape, start position, ;; heading (to a random direction) and that they aren't ;; carrying food ask-turtles[setc red setshape termite-shape setxy 0 0 seth random 360 sethasFood? false] end to setup-patches ;;set the chemlevel of all patches to 0 and ;; setup the location of the nest ask-patches[setchemlevel 0 setisNest? ((distance 0 0) < 4)] setup-food-1 setup-colors end to setup-food-1 ;;set the location and amount of food sources ask-patches [setfood 0 if ((distance (0.6 * screen-half-width) 0) < 4) or ((distance (-0.8 * screen-half-width) (0.8 * screen-half-width)) < 4) or ((distance (-0.5 * screen-half-width) (-0.5 * screen-half-width)) < 4) [setfood random 10] ] end to setup-colors ;;color the screen ask-patches [ if isNest? [setpc blue] ] ask-patches [ if food > 0 [setpc purple] ] end to evaporate-with-delay ;;only evaporate every 500 iterations setcount count + 1 if count = 500 [ setcount 0 ;;reduce the amount of chemical on each square ;; and recolor the screen ask-patches[ if not (chemlevel = 0) [setchemlevel chemlevel * evap-rate / 100] if (chemlevel < .1) [setchemlevel 0] if ((not (isNest?)) and (not (food > 0))) [scale-pc green chemlevel .1 10] ] ] end