It turns out that my latte daydream, as brief as it was, simulated the basic symptoms of attention-deficit/hyperactivity disorder or ADHD, a neurobehavioral condition that affects at least 6 million children. I’m sitting in a little room off the library of the Churchill School, a private day school in the Kips Bay section of Manhattan’s East Side. Churchill specializes in educating children with attention problems, and as one of their therapies they’re piloting this game, created by a Massachusetts outfit called Atentiv. Developed in collaboration with Duke University neuroscientist Ranga Krishnan, it’s part of a burgeoning field called therapeutic neurogaming, which turns the mechanics of digital games into actual therapy that its proponents say can calm kids down, focus them, and help them overcome debilitating conditions like ADHD, anxiety disorder, depression, and even, in the near future, certain types of autism, so they can concentrate on schoolwork. It’s built on two basic ideas: First, that the brain is “plastic” for far longer than scientists once believed, so healing can be achieved in schoolchildren of all ages without drugs, through basic neurofeedback therapy. Second, that therapy doesn’t just happen — it requires work and patience and a regular dose of practice. Since games encourage people to spend time playing them, the theory goes, players will return to them regularly. Patients are more likely to make progress with a therapeutic game than with regular therapy that may be tiresome or dull. In medical terms, people who are playing an absorbing game will take all of their medicine.

The stakes are high. In 2011, the federal Centers for Disease Control and Prevention estimated that health-care providers had returned ADHD diagnoses for more than one in ten school-aged children and one in five high-school boys. The percentage of children taking medication for ADHD, as reported by their parents, grows about 7 percent each year. In 2011, an estimated 3.5 million children were taking ADHD medicine, 1 million more than in 2003. The U.S. Food and Drug Administration has warned that side effects for Ritalin, one of the most popular ADHD drugs, can include high blood pressure, stroke, heart attacks, and, for users with heart problems, sudden death. The FDA also says Ritalin can stunt children’s growth and give them blurred vision, headaches, seizures, decreased appetite, nausea, sleeplessness, and, for young men, “painful and prolonged erections.” It can also cause psychiatric problems, including bipolar disorder.

So for the past few years, a small group of psychiatrists, researchers, educators, and game designers have run a quiet but intense footrace to become the first to earn FDA approval for a medically sound, prescription-strength video game for ADHD. That’s not a metaphor. They are seeking approval for a game that a doctor can actually prescribe.

The problem with drugs like Ritalin or Adderall, researchers say, isn’t just that they have side effects. It’s that they’re almost entirely hit or miss. They activate “your entire brain, in a very blunt way,” said Dr. Adam Gazzaley, a psychiatrist and founding director of the Neuroscience Imaging Center at the University of California–San Francisco. “We don’t really have a selective way to target their effects, and because of that we have to increase their doses to very high levels,” he said. Most drug-prescription guidelines for doctors are entirely nonpersonalized, based on population data rather than the needs of the patient sitting in front of them. And once they’ve got the medicine, he said, there’s an inherent delay between the time a patient takes it and the time that a doctor sees the effects, usually during the next office visit. “We have this very open-loop system, and I maintain that this is just really not good enough,” Gazzaley said. A few years ago, he began searching for a new way to treat his patients, for a tighter feedback loop that was “targeted, personalized, multimodal, and closed-loop.”

Gazzaley got interested in video games after reading medical literature that showed first-person shooters improved the cognitive abilities of players, both expert and naïve. He knew that as we get older, we have a harder time switching between different tasks, partly because of a phenomenon he calls “stickiness of perception.” Like doors hanging on rusty hinges, as we age our brain develops difficulty swinging from task to task, not only because it’s hard to swing over to the new task, but because it’s difficult to disengage from the old one. Gazzaley began wondering if he could develop a game to enhance this switching in older adults. At the time, a few of his friends were working for the game developer LucasArts, so he asked if they’d be interested in helping him out. They said they’d be delighted. “Their perspective was that they’d been teaching teenagers how to kill aliens for fifteen years now — most of their professional life — and they were looking forward to the opportunity to work on games that might have a different kind of impact.”

Gazzaley’s team developed NeuroRacer, an immersive 3-D cognitive trainer that, in many ways, resembles the Atentiv chicken game, though it predates it. NeuroRacer requires players to steer an animated racecar down a winding road while reacting to different colored shapes along the way. If players see a green sign, they press a button. If they see a red or blue sign, they try to ignore it. As they improve their multitasking skills, the game gets harder, but if players can’t handle the simultaneous tasks, the game gets easier. That is its “special sauce,” Gazzaley said. Unlike the real world, where as you get better at a task it gets easier, in NeuroRacer, reality is reversed in the name of science.