The courtship behavior of Drosophila melanogaster serves as an excellent model system to study how complex innate behaviors are controlled by the nervous system. To understand how the underlying neural network controls this behavior, it is not sufficient to unravel its architecture, but also crucial to decipher its logic. By systematic analysis of how variations in sensory inputs alter the courtship behavior of a naïve male in the single-choice courtship paradigm, we derive a model describing the logic of the network that integrates the various sensory stimuli and elicits this complex innate behavior. This approach and the model derived from it distinguish (i) between initiation and maintenance of courtship, (ii) between courtship in daylight and in the dark, where the male uses a scanning strategy to retrieve the decamping female, and (iii) between courtship towards receptive virgin females and mature males. The last distinction demonstrates that sexual orientation of the courting male, in the absence of discriminatory visual cues, depends on the integration of gustatory and behavioral feedback inputs, but not on olfactory signals from the courted animal. The model will complement studies on the connectivity and intrinsic properties of the neurons forming the circuitry that regulates male courtship behavior.