Comparison of solitary and collective foraging strategies of Caenorhabditis elegans in patchy food distributions