It’s important to distinguish between cravings and ordinary or “physiological” hunger. The latter is a sense that you need to take in almost any reasonably palatable food that offers calories. It’s triggered largely by the body’s signs that it’s running low on available energy, like low blood sugar, an empty stomach, or a slight anticipatory rise in insulin levels.

One reason cravings are so hard to resist is that they hijack these hunger-signalling mechanisms. “If you walk into a doughnut shop for a cup of coffee after breakfast and see them making doughnuts, you can experience the same drop in blood glucose, and the same slight surge in insulin,” says Roberts. “You’ll even get an empty stomach feeling, because your stomach suddenly relaxes and expands.”

Why do we crave particular foods? The classic take is that cravings are often related to nutritional deficiencies — a “wisdom of the body” to push us to eat what we most need. But there’s now a mountain of evidence that the notion of such so-called tonic cravings is mostly myth, based on wishful thinking and older research that hasn’t held up. Those famous studies of rats and even children who, presented with the option of eating junk food or healthy food, eventually steered themselves to a balanced diet? They were overturned long ago by more careful studies. “If you develop a serious vitamin or other nutrient deficiency, you might get ill and lose your appetite for what you’ve been eating, possibly leading you to try other foods,” says University of Michigan PhD neuroscientist Kent Berridge. “But you won’t crave something because it has the missing nutrients.”

Even the most enduring symbol of tonic cravings — pregnant women fixating on odd foods that supposedly meet some demand of their changing bodies — hasn’t held up to scrutiny. The hormonal roller-coaster of pregnancy might drive peculiar preferences, says Berridge, but not in a way that’s tied to health. “There’s nothing in a pickle that could even meet a nutritional need,” says Berridge. He notes that there are a few types of nutrient shortages that might actually tie to cravings, including a lack of salt from intense sweating, and possibly — though the evidence is mixed — a lack of calcium and iron.

Vegetables, whole grains, most fruits, and lean protein can all be crossed off the list of foods people crave. It’s certainly possible to like these generally healthy foods — even love them — and actively seek them out and savor them. But as a rule, people don’t crave them to the point of being powerless to resist eating them. “I’ve never met anyone who struggles with vegetable cravings,” says Sherry Pagoto, a PhD behavioral psychology researcher at the University of Connecticut.

“Cravings were a good thing for evolution to give us in the face of food scarcity. Now, in this special time of food plenty, it’s not a good thing. It’s why most of the population is overweight.”

Virtually every scientist who has studied cravings comes to the same conclusion: What people desire is food that packs in a relatively large number of calories per bite. Blame 500 million years of animal and eventually human evolution, approximately 99.9999% of which featured the constant threat of starvation. In that circumstance it makes sense that evolution favored a drive to gobble first and ask questions later when presented with a chance to score a day’s worth of precious calories in a package that can be swallowed in 30 seconds. Hunger was irrelevant to this picture — an extra glob of high-energy food could be stored as body fat for the once inevitable days when food wouldn’t be available.

In the 20th century, the once life-saving push to lust after energy-dense foods became much more likely to work against health. “Cravings were a good thing for evolution to give us in the face of food scarcity,” says Pagoto. “Now, in this special time of food plenty, it’s not a good thing. It’s why most of the population is overweight.”

A study from the National Institutes of Health published in May found a striking way to test the notion that calorie density carries the day when it comes to eating urges. The study found that people presented with calorie-dense meals — that is, rich, fatty, sugary junk foods — repeatedly and consistently ate more calories than people presented with less calorie-dense foods like fruit and lean protein. And that was true even though both groups of people were always presented with initial servings representing the same number of calories’ worth of protein, carbohydrates, and fat, and were free to leave some of the food on the plate or go for extra servings. Think of it this way: An apple and two bites of a fudge brownie sundae each contain the same number of sugar calories — but while most people wouldn’t reach back into the bowl of fruit after eating the apple, few people would be able to push away the sundae after two bites.

While the link between cravings and calorie-dense foods is fairly ubiquitous, that doesn’t mean people crave the same foods with the same intensity. And therein lies the roots of humans’ vulnerability to food industry manipulation — as well as the source of potential freedom from health-destructive cravings.

Cravings have a strong genetic component, given that the basic preference for foods with higher calorie density cuts across generations, geography, and culture. But the fine-tuning of those cravings is mostly programmed in at an early age, and is usually related to the particular foods presented during childhood. A study of children in Mexico found that when kids were very young, they showed little interest in spicy foods until around age 5, when they suddenly began to prefer the same hot dishes their parents and older siblings were eating. Those preferences eventually morphed into lifelong cravings for spicy, high-calorie-density dishes, cooked in certain ways. But even within cultures, says Roberts, the preferences tend to vary from person to person, and in individuals they can vary over time, and in different situations.

In spite of cravings variability, the biological and especially neurological mechanisms that create cravings — as well as the sorts of environmental factors that trigger them — are fairly universal. “Hormones and other chemicals percolate up from the gut and liver, creating signals that move up the vagus nerve into the brain’s hypothalamus, which cranks up the release of dopamine, which drives intense desire and reward,” says Berridge. The resulting intense urge to eat whatever particular food spurs cravings is linked to brain processes controlled by leptin, the hormone released after a meal to create a sense of satiety. Your belly may be bulging with turkey and stuffing, but then the pecan pie is placed on the table. The leptin mumbles “no,” but the dopamine shouts “go for it.”

Though cravings are programmed into the brain, they are mostly just lying in wait. What sets them off is some sort of input from the senses — typically a sight or smell. And here’s where Big Food rules: Experts say that marketers have learned to take advantage of triggers to point people toward the commonly craved, high-calorie-density foods they produce.

Spence, of Oxford University, has studied food industry manipulations extensively. He says images on food packaging often depict serving sizes that are, on average, three times as generous as the portion suggested in the nutrition label, that malls put cafes and bakeries near staircases to ensure enticing smells get pumped throughout the building, and that food porn and other images of high-calorie delights on Instagram or advertisements are often shown as if from the eater’s point of view. “Nothing gets the brain so activated as the sight and smell of food,” says Spence. “You lock right in on it, and you picture yourself putting it in your mouth and chewing it; you imagine how good it would taste.”

People are also bombarded with access to junk food: There’s multiple McDonald’s or Starbucks or Dunkin’ Donuts at seemingly every corner. “Our environment gives us a very ready supply of calorie-dense foods,” says Hall. “Lower-calorie options are more difficult to seek out.”

Yet researchers have also uncovered some tricks for avoiding or tamping down the dopamine fire that rages when triggers strike. Some of these tricks involve distraction. One that Roberts says is weirdly successful is to tap your forehead and count backwards from 100 when you’re hit by an urge to eat. “Cravings tend to happen in shorter-term memory,” she explains. “You can push them out by focusing on a task.” A walk around the block can work, too, she says.

Researchers have discovered a real and entirely unexpected bonus to resisting the cravings-driven urge to consume junk, says John Apolzan, PhD, a nutrition scientist at Louisiana State University: If you can kick the objects of your cravings out of your diet even for just a few weeks, the cravings start to fade. “Earlier research suggested cravings should skyrocket when you resist them,” says Apolzan. “But now it’s clear that’s just not true.” The reason they diminish, apparently, is that cravings are the product of habit — the more often you give in to your cravings, the stronger and more fixed they become. Changing your habits seems to reverse the process, says Apolzan.

To support that effort, Pagoto urges remaking the environment. You can’t get rid of the Cinnabon near your workplace, but you can make a point of rerouting your commute so you don’t pass it. “You have to figure out the one hundred cues that are triggering the cravings,” says Pagoto. “It’s not just the food itself; it’s the things you’ve learned to associated with the foods. If you have ice cream on the couch every night, you’ll want ice cream as soon as you sit on the couch, or when you see the bowl you usually eat it in.” To make identifying those hundreds of triggers easier, Pagoto and her colleagues have developed an app. Simply press an “oops” button every time an unhealthy craving is indulged, and enter a few notes about what was going on when you caved to the craving. At the end of the week, the app provides a report on what times of day, locations, objects, or actions might be your triggers.

Pagoto says she’s found that people report healthier diets and even weight loss simply by using her app to hit the “oops” button after indulging a less healthy craving — even if they didn’t use the results to change their environment. “We didn’t expect using the button to stand alone as an intervention,” she says. “But now we wonder if that might be enough.”

Some of the most recent research suggests people may be able to more directly protect their brains against craving triggers through the right sort of stimulation. Hall, who runs the TMS experiments, says he’s looking into using the device as part of a treatment for obesity. In the lab he uses the TMS to temporarily impair the dorsolateral prefrontal cortex — the part of the brain that can muster resistance to craving triggers — while at the same time leaving a picture of junk food in the subjects’ field of vision. The combination leads people to eat more chocolate and chips. But he’s also found that impairing the region while displaying healthy food images reduces the urge to overindulge, suggesting a potential aid to losing excess weight. “We think when combined with coaching, it might be a good alternative to gastric bypass surgery,” he says.

TMS machines go for $70,000 and require trained technicians and clinicians to operate, so don’t count on home versions any time soon. A handier new way to bolster the brain’s resistance to cravings could be a gamified app from researchers at the University of Exeter in the U.K. Users score points by quickly and repeatedly distinguishing fleeting images of foods for which they have an unhealthy weakness from foods considered healthier alternatives. The researchers admit they don’t quite understand why it helps reduce cravings, but have confirmed in studies that it does. It’s possible that associating a brief decision-making process with scoring highly helps the brain do a better job when confronted with real-world decisions between junkier and healthier options.

More apps and other tricks for fighting cravings are likely on the way. Could they go as far as to flip cravings so people want to eat veggies and other healthy foods? That doesn’t seem to be in the cards yet, according to researchers. But cutting down on the unhealthy cravings is a huge step in the right direction.