They were young males on the make, and they struck out not once, not twice, but a dozen times with a group of attractive females hovering nearby. So they did what so many men do after being repeatedly rejected: they got drunk, using alcohol as a balm for unfulfilled desire.

And not one flew off in search of a rotting banana.

Fruit flies apparently self-medicate just like many humans do, drowning their sorrows or frustrations for some of the same reasons, scientists reported Thursday. Male flies subjected to what amounted to a long tease — in a glass tube, not a dance club — preferred food spiked with alcohol far more than male flies that were able to mate.

The study, posted online in the journal Science, suggests that some elements of the brain’s reward system have changed very little during evolution, and these include some of the mechanisms that support addiction. Levels of a brain chemical that is active in regulating appetite predicted the flies’ thirst for alcohol. A similar chemical is linked to drinking in humans.