Jovanoski et al.5 show that, in a region of the fruit-fly brain called the mushroom body, distinct subpopulations of neurons that release the neurotransmitter dopamine can reinforce either the seeking of a reward or the avoidance of a punishment. a, Typically, the activity of punishment-encoding neurons (red) overcomes that of reward-encoding neurons (blue), causing fruit flies to avoid an odour cue associated with an electric shock. b, When the odour cue is paired with artificial stimulation of reward-encoding neurons, however, fruit flies will endure an electric shock in pursuit of the odour. Dysregulation of a similar network of opposing dopamine neurons in humans could be responsible for unconstrained reward-seeking behaviour, a feature of addiction.