Animals have evolved diverse behaviors that serve the purpose of finding food in the environment. We investigated the food seeking strategy of the soil bacteria-eating nematode Caenorhabditis elegans. C. elegans bacterial food varies in quality: some species are easy to eat and support worm growth well, while others do not. We show that worms exhibit dietary choice: they hunt for high quality food and leave hard-to-eat bacteria. This food seeking behavior is enhanced in animals that have already experienced good food. When hunting for good food, worms alternate between two modes of locomotion, known as dwelling: movement with frequent stops and reversals; and roaming: straight rapid movement. On good food, roaming is very rare, while on bad food it is common. Using laser ablations and mutant analysis, we show that the AIY neurons serve to extend roaming periods, and are essential for efficient food seeking.