I’m not what you’d call a coordinated man, so basketball horrifies me. All the dribbling, all the shooting—all while running and dodging people trying to smack the ball out of your hands. Basketball players have to be one with the laws of physics. I am not one with the laws of physics.

Now imagine teaching the machines something as complicated as dribbling—which is exactly what researchers at Carnegie Mellon University and a startup called DeepMotion have done. Using motion-capture technology, they’ve shown an algorithm generally how humans move when they dribble. Then, thanks to a process called reinforcement learning, a simulated basketball player can teach itself through trial and error how to finely manipulate the ball, both while stationary and while running. It’s taught itself to expertly do what would thoroughly embarrass an … underactive type like myself.

The researchers began by putting people in motion-capture suits to watch them dribble. This gave the reinforcement learning algorithms a good head start. You could try to have an avatar learn from scratch: First to stand, then to walk, then to run, then to manipulate a ball. To do that, you give the system a goal—say, move forward as fast as possible—and it tries movements at random. If the avatar does something that gets it closer to its goal, like combining random movements in order to stand, it gets points. If it does something dumb, it gets dinged. With a point system like this, over time it teaches itself how to run.

That’s not a good way to go about it in this case, though. “If you're trying to do something easy, then maybe you can just explore the space and flail around much like a baby does as it's sort of figuring out how to grab things and so on,” says CMU roboticist Jessica Hodgins, who helped develop the system. “But it doesn't make sense in this complicated space of doing something that requires as much agility as basketball dribbling.”

So instead of starting from scratch, the motion-capture information allows the avatar to mimic a dribbling human’s body movement. What the researchers couldn’t capture, though, was the ball itself—it moves too fast, and you can’t stick trackers on it. They had to add the ball into the simulation, and let the avatar play with it through reinforcement learning, or trial and error.

Carnegie Mellon University Carnegie Mellon University

Take a look at the GIF above. The avatar’s dribbling starts out awkward at first, but soon improves. “You're reinforcing the behaviors that you want and then negatively reinforcing the behaviors that you don't want,” says Hodgins. “You're doing that by running many, many trials and having the system learn through those trials to be more robust to different kinds of situations.”