The ability of an animal to locomote through its environment depends crucially on the interplay between its active endogenous control and the physics of its interactions with the environment. The nematode worm Caenorhabditis elegans serves as an ideal model system for studying the respective roles of neural control and biomechanics, as well as the interaction between them. With only 302 neurons in a hard-wired neural circuit, the worm's apparent anatomical simplicity belies its behavioral complexity. Indeed, C. elegans exhibits a rich repertoire of complex behaviors, the majority of which are mediated by its adaptive undulatory locomotion. The conventional wisdom is that two kinematically distinct C. elegans locomotion behaviors – swimming in liquids and crawling on dense gel-like media – correspond to distinct locomotory gaits.

We use a combination of behavioral assays, simulation tools and computer generated models to study C. elegans locomotion across a range of different physical environments. We present quantitative descriptions of the worm's locomotion as well as the relevant rheological parameters of the environments in which it moves. In particular, we use this system to provide a detailed account of the role of agar in shaping the locomotion. Using these tools, we are also able to present a unified picture of C. elegans locomotion across these different environments. We validate our experimental conclusions with computer simulations that explicitly incorporate the physics of the environment. We demonstrate that we can virtually replicate C. elegans waveforms, motion trajectories, turning, and responses to environmental constraints. Finally, we discuss specific predictions and implications of our results for understanding both the physical properties of the worm and its neuromuscular control.