to search-for-food if food > 0 [if not hasFood? [sethasFood? true setshape termite-wood-shape rt 180 setfood food - 1 if food = 0 [ ask-patch-at xcor ycor [setpc black] ] ] ] if isNest? [if hasFood? [sethasFood? false setshape termite-shape rt 180] ] find-best-path drop-chem wiggle fd 1 end to find-best-path setahead next-chemlevel lt 90 setleft next-chemlevel rt 45 setupleft next-chemlevel rt 90 setupright next-chemlevel rt 45 setright next-chemlevel lt 90 if (right > ahead) and (right > left) and (right >= upright) and (right > upleft) [rt 90 stop] if (left > ahead) and (left > right) and (left > upright) and (left >= upleft) [lt 90 stop] if (upleft > ahead) and (upleft > right) and (upleft > upright) and (upleft >= left) [lt 45 stop] if (upright > ahead) and (upright > left) and (upright >= right) and (upright > upleft) [rt 45 stop] end to drop-chem ifelse hasFood? [setchemlevel chemlevel + .1] [setchemlevel chemlevel + .2] if not (isNest? or food > 0) [scale-pc green chemlevel .1 10] end to wiggle rt random 20 lt random 20 end to next-chemlevel output chemlevel-at dx dy end