Spatial orientation behavior is universal among animals, but its neuronal basis is poorly understood. The main objective of the present study was to identify candidate patterns of neuronal connectivity (motifs) for two widely recognized classes of spatial orientation behaviors: hill climbing, in which the organism seeks the highest point in a spatial gradient, and goal seeking, in which the organism seeks an intermediate point in the gradient. Focusing on simple networks of graded processing neurons characteristic of Caenorhabditis elegans and other nematodes, we used an unbiased optimization algorithm to seek values of neuronal time constants, resting potentials, and synaptic strengths sufficient for each type of behavior. We found many different hill-climbing and goal-seeking networks that performed equally well in the two tasks. Surprisingly, however, each hill-climbing network represented one of just three fundamental circuit motifs, and each goal-seeking network comprised two of these motifs acting in concert. These motifs are likely to inform the search for the real circuits that underlie these behaviors in nematodes and other organisms.