My local pharmacy is offering flu shots. The sign grabbed my attention the other day, because it was a sweltering, muggy day, and it seemed way too early to think about winter flu bugs. But a little digging proved me wrong. The vaccine takes a couple weeks to click in, and seasonal flu bugs can arrive as early as October. So I did the arithmetic, and I’m lining up to get poked.

I’ve gotten flu shots for years, though I’m not in any high-risk group. It just seems prudent to me. And the fact is, public health officials count on people who are at low or moderate risk to get inoculated anyway. The elderly get the sickest, and sick more often, but young people—children especially—are the ones responsible for spreading germs around, so the goal is to create “herd immunity” that protects the most vulnerable. Kids, in effect, are being asked to take on the risks of vaccination to protect the elderly.

This complex dynamic presents an intriguing social and psychological dilemma—one that Rutgers University psychological scientist Gretchen Chapman wanted to explore in the laboratory. She and her colleagues wanted to examine the conditions under which young people would make this trade-off, getting vaccinated to protect the elderly—and when they would not.

She turned to game theory to mirror real-world flu transmission. Game theory posits a social situation in which the individual faces a choice between two options, one entirely self-interested and the other beneficial for the group as a whole. Vaccination adds some twists to the standard dilemma, because risk and payoff vary with age, and vaccination does not serve everyone’s self-interest equally. Chapman hoped to use a modified game theory experiment to illuminate people’s motivations for getting flu shots.

She used a computer task to simulate the decisions that both young and old people make about flu shots. Nearly 300 volunteers were given detailed instructions about how flu vaccines work and how effective they are; the difference in risk for the young and the elderly; and the importance of wide participation for herd immunity and the collective social welfare.

Some volunteers played the role of an older person; others a young person. Younger people paid more “points” if they chose to buy protection from the bug, while the elderly lost more points if they did become infected. The volunteers knew in advance that the points were redeemable for cash, but some were told that payment would be based on individual accumulated points; others learned that payout would be based on total group points. In other words, some were acting out of pure self-interest, while others were also mindful of their part in the group’s outcome.

Based on all of this information, all the volunteers made a series of private choices about whether or not to get a flu shot. Then the hypothetical flu season hit. Some volunteers, both old and young, subsequently got the flu, while others did not—as determined by an epidemiological model of age and risk. The vaccine was 80 percent effective for young people, 50 percent effective for the elderly.

How did the public health campaign do? Chapman discusses the results in the on-line version of the journal Psychological Science. When volunteers were paid according to individual point totals, more elderly people got vaccinated than did young people. That is, everyone acted out of their own self-interest, without regard for the public health. But when volunteers were paid based on group point totals, more young people got flu shots, and the whole population benefited. Indeed, the total accumulated points of the whole group exceeded all self-interested gains added together.

What this suggests is that young people can learn to act in the overall interest of society. If they are made to understand the flu’s risks and benefits and the idea of herd immunity, they may be motivated to get vaccinated for someone else’s benefit. If they do not comprehend this dynamic, both young and old people default to self-interested motivations.

Of course, decisions are not so tidy back in the real world of germs and disease and human emotion. People—the elderly and youthful, parents of the very young—make vaccination choices for many and complex reasons. But these results do suggest that young people might voluntarily assume some risk to safeguard society’s most vulnerable, if the incentives are right. Those incentives might include fear of social disruption, personal concerns about older family or friends, or simply good citizenship.

Wray Herbert’s book, On Second Thought, is about irrational decision making. Excerpts from his two blogs—“Full Frontal Psychology” and “We’re Only Human”—appear regularly in The Huffington Post and in Scientific American Mind.