# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# ants.Ant.forage()

## Syntax

    ant.forage(speed=2)

## Description

An ant's main decision loop. Each time forage() is called, the ant checks whether it is going to wander randomly, follow a trail or harvest food.

An ant has useful properties which you can check to see what the ant is doing:

- ant.x: the ant's current x position
- ant.y: the ant's current y position
- ant.hasfood: True when the ant is carrying a unit of food
- ant.trail: a list of pheromones marking the path from the food source to the colony. Each pheromone in the list has an x and y property determining it's location and a strength property (after some time the pheromone scent evaporates).