New Discovery Biodiversity Published: June 16, 2026

Using AI to Study Fighting in Female Fruit Flies

Abstract

Animals fight over things they need. Males fight more than females, but females also fight. We studied how female fruit flies fight over food. We thought that females would need more food after mating, when they produce eggs. We measured fighting in eight species of fruit flies using artificial intelligence to measure how many times females fought. We found that females decrease fighting after mating or do not fight much at all. Females who produce lots of eggs fought more than females that produce few eggs. We think this means that the value of food increases when females lay many eggs.

Why and How do Animals Fight?

Animals fight for access to resources that they need to survive and have babies. Resources may include food, a place to live, and reproductive partners. Fighting is dangerous. An animal risks getting hurt, or even dying, when it fights. This means that it should only fight if the benefit of the resource outweighs the cost of injury.

Many male animals have spectacular fights. For example, male deer charge each other with their antlers. Small animals, such as insects, can also fight, including fruit flies with the scientific name Drosophila. Male fruit flies fight over food and females. Researchers use these flies to understand how animals fight. Did you know that females fight, too? We do not see it as often, but females also fight each other. How much a female fights depends on what she needs. Females that are pregnant or about to lay eggs need lots of food to produce babies. For example, a female D. melanogaster who has mated fights longer than a female that has not mated [1].

In the lab, we watch female fruit flies fight over yeast, a food they like to eat. Yeast is found on rotting fruit. When fighting, a female D. melanogaster headbutts her opponent! She thrusts her head at another female, hitting the other fly (Figure 1). This may cause the opponent to back away from the yeast or headbutt back.

Panel A shows a blurred grayscale image of two insects with an arrow labeled “yeast” pointing to one. Panel B is a flowchart outlining steps: video record two females, run video through tracking program, teach AI program what is a headbutt, check AI performance, and, if high accuracy, count number of headbutts in all videos; if low accuracy, reiterate training.
  • Figure 1 - (A) Headbutting Drosophila females.
  • Although headbutts are often to the side of another female, in this case the females are headbutting straight on. They are fighting over the patch of yeast. (B) The flow chart of the steps we use to study fly fighting.

How do we Measure Fighting?

To measure fighting in female fruit flies, we place two females together with a spot of yeast. They are placed on top of an infrared light so we can see the flies clearly. This type of light makes our photos look like black-and-white outlines of the flies (Figure 1A). We digitally video record the flies using a special camera. Our set up allows us to record 20 pairs at a time. We let the flies fight for 15 min, then we stop the recording and start the analysis. We could watch every video and count every headbutt, but that takes a lot of time. Instead, we use an artificial intelligence (AI) computer program to count headbutts. We do this in two steps.

In the first step, we run the video through a computer program that identifies each fly and tracks what they are doing at all times (Figure 1B). Videos are made of up of lots of individual photos—we record at 30 photos per second! The tracking program looks at each photo and records in which photos the flies are moving, how fast they are moving, and how close they are to the other fly. The program converts this to numbers that describe movement, which is called tracking data.

Once every fly is tracked, we move to the next step: training the AI program. You may have seen an AI program where you can give it a picture, and it can tell you whether the photo contains a cat or a dog. We use a similar type of AI on the photos from our videos, but we teach AI how to tell when flies are fighting or not. We watch a few videos and tell the computer when flies are fighting and when they are not. The AI program compares the tracking data for fighting and not fighting (e.g., by seeing whether the flies are moving and how close are they to other flies). We then give the AI program a video we did not watch, and it identifies whether the flies are fighting or not (like saying if there is a cat or a dog in the photo). We can then check how well the computer did and retrain it until it is accurate. Once the program understands what headbutts are, the program finds the headbutts in all the videos. If we counted every headbutt ourselves, each experiment would take us about 20 h. Using the AI procedure, we can count the headbutts in an experiment in less than an hour.

How Much do Fruit Fly Females Fight?

There are thousands of species of fruit flies. Each species has its own habitat, food, and egg laying habits. Species vary in their needs for resources. We wanted to know if species vary in how much females fight and if mating changes their fighting. Although we knew a lot about D. melanogaster females [1], we did not know much about female fighting in other species. We measured fighting in eight other species of Drosophila. The first thing we noticed was that some species fought a lot, while others fought very little (Figure 2) [2]. Unlike D. melanogaster females, who fight more after mating than before mating, some of these species decreased how much they fought after mating. You can see this in D. pseudoobscura in Figure 2 if you compare the orange bar (unmated females) to the blue bar (mated females). For some species, the amount of fighting did not change after mating. Although D. melanogaster seems to need food more after mating, other species may need food more before mating, or mating might not change how much food they need to eat.

Bar chart comparing the amount of headbutting among unmated and mated females across eight Drosophila species. D. pseudoobscura unmated females show the highest headbutting, while D. willistoni exhibits the least in both groups.
  • Figure 2 - Variation in fighting.
  • Some species, such as D. pseudoobscura, fought much more than other species, such as D. willistoni. For all species, unmated females fought the same amount or more than mated females.

How Might the Need for Food Vary Among Fruit Flies?

Different species of fruit flies lay different numbers of eggs. Laying many eggs requires more food than laying very few eggs. The number of eggs a female can lay is determined by the number of ovarioles a female has. An ovariole is the part of an insect ovary that produces an egg (Figure 3A). Across Drosophila species, each ovary has one to 89 ovarioles [3]. Females of species with many ovarioles can lay more eggs than species with few ovarioles.

Panel A shows a labeled diagram of an insect ovary, with indications of the ovary, ovarioles, and eggs. Panel B presents a scatter plot illustrating a positive correlation between number of ovarioles and amount of headbutting, with each orange dot representing a data point and a dotted trend line suggesting this relationship.
  • Figure 3 - Ovarioles and fighting.
  • (A) Two fruit fly ovaries. A single ovariole has been pulled away from the right ovary to show that an ovary is made of strands of ovarioles with one egg per ovariole. (B) Females with many ovarioles headbutt more than females with few ovarioles.

We predicted that females in species with more ovarioles fight more than females in species with fewer ovarioles. If a female does not lay many eggs, she may not need much food. If she does not need the food, she might not fight. We found that females of species with many ovarioles tend to fight more than females of species with few ovarioles (Figure 3B). We cannot say that ovarioles cause females to fight, but that the number of ovarioles and how much they fight are related. Now we have more questions about what makes females fight.

What is Next?

Now that we know that laying eggs and fighting are linked, we can explore the relationship in more detail. Do the patterns we see comparing different species look the same if we look within species? For example, in our very aggressive D. pseudoobscura, if some females have more ovarioles than others, do they fight more? We also want to know if females fight over other resources. For some species, males can be hard to find. In those species, we predict that females fight over males rather than over food. We also do not know if males of other species differ much in how they fight. We would like to know if species with very aggressive females also have very aggressive males.

The next time you have fruit flies in your kitchen, take a minute and watch them. If you see one fly bump into another one, it just might be a female fighting for food.

Glossary

Headbutt: A behavior in which one female hits another with her head, usually striking the other female’s side.

Artificial Intelligence (AI): Computer programs designed to perform tasks that usually require human thinking, such as recognizing patterns, learning from data, solving problems, or helping people make decisions.

Tracking Data: Numbers that describe each fly in every video frame, including its position, speed, and the direction it is facing compared to the other fly.

Ovariole: A section of an insect ovary that forms individual eggs. The number of ovarioles indicates how many eggs a female can lay each day.

Ovary: The sex organ that produces eggs.

Conflict of Interest

The author(s) declared that this work was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Acknowledgments

This work was supported by the National Science Foundation, IOS-2121849, to JG and a research grant from Association for the Study of Animal Behaviour to EB. The funders provided funding and did not influence the research.

AI Tool Statement

The author(s) declared that generative AI was not used in the creation of this manuscript.

Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.


Original Source Article

Bath, E., and Gleason, J. M. 2025. Is variation in female aggressiveness across Drosophila species associated with reproductive potential? Proc. R. Soc. London Ser. B 292:20242301. doi: 10.1098/rspb.2024.2301


References

[1] Bath, E., Bowden, S., Peters, C., Reddy, A., Tobias, J. A., Easton-Calabra, E., et al. 2017. Sperm and sex peptide stimulate aggression in female Drosophila. Nat. Ecol. Evol. 1:0154. doi: 10.1038/s41559-017-0154

[2] Bath, E., and Gleason, J. M. 2025. Is variation in female aggressiveness across Drosophila species associated with reproductive potential? Proc. R. Soc. London Ser. B 292:20242301. doi: 10.1098/rspb.2024.2301

[3] Sarikaya, D. P., Church, S. H., Lagomarsino, L. P., Magnacca, K. N., Montgomery, S. L., Price, D. K., et al. 2019. Reproductive capacity evolves in response to ecology through common changes in cell number in Hawaiian Drosophila. Curr. Biol. 29:1877–84. doi: 10.1016/j.cub.2019.04.063