to go-to-nest find-nest drop-chem wiggle fd 1 end to search-for-food find-best-path wiggle fd 1 end to search 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] ] ifelse hasFood? [go-to-nest] [search-for-food] end to find-best-path setahead next-chemlevel lt 45 setleft next-chemlevel rt 90 setright next-chemlevel lt 45 if (right > ahead) and (right > left) [rt 45 stop] if (left > ahead) and (left > right) [lt 45] end to find-nest setahead next-nest-scent lt 45 setleft next-nest-scent rt 90 setright next-nest-scent lt 45 if (right > ahead) and (right > left) [rt 45 stop] if (left > ahead) and (left > right) [lt 45] end to drop-chem setchemlevel chemlevel + .1 if not (isNest? or food > 0) [scale-pc green chemlevel .1 10] end to wiggle rt random 40 lt random 40 end to next-chemlevel output chemlevel-at dx dy end to next-nest-scent output nest-scent-at dx dy end