Scientists have developed robots that use a trial-and-error algorithm to adapt to damage in under two minutes. (Jean-Baptiste Mouret via Youtube)

Whelp, now we're one step closer to indestructible killer robots! Just kidding. Probably. Maybe? Hopefully.

In a study published Wednesday in Nature, researchers report a robot that can adapt to "injury" by quickly learning to move in spite of damaged limbs. In less than two minutes, the six-legged creature can learn to compensate for two broken legs. Using the same technique, the researchers also created a robotic arm that could continue to move objects in spite of multiple malfunctioning motors.

"Robots will eventually provide tremendous benefits to society, especially if they can complete tasks too dangerous for humans to perform," study author Jeff Clune of the University of Wyoming told The Post. Many roboticists hope their creations will end up digging for survivors in treacherous rubble and fighting deadly fires in man's stead. "But robots won’t be effective in those situations if they can’t adapt and continue on after being damaged," Clune said.

[How a robot ended up teaching exercise classes in a Dutch retirement home]

A robot can easily overcome damage if it's able to work through the different ways it can move its body. By using a learning algorithm to try out different ways of moving, a robot can come up with a new gait. But that usually takes hours.

"The robot has to search intelligently through the space of all possible behaviors," Clune said. "It’s larger than the number of molecules on planet earth, it’s like finding one of a few needles in a field of haystacks."

To speed up the process when performance is crucial, Clune and his collaborators gave their robots what he calls a "simulated childhood." Before being operated, they spend several hours going through simulations.

One of the adaptable bots. (Antoine Cully)

"It plays for a while," Clune said. "It learns lots of ways to move its body, just like a child saying, 'Oh, I can walk on my tippy toes, I can hop on one foot.'"

So just like a human or other animal, the injured robot is able to find a solution without working from scratch: It has an intuitive sense of the different motions its body can go through, so it adapts to loss of limbs and motors much more quickly than it otherwise could.

[After years of paralysis, a man drinks a beer with the help of a mind-reading robot]

Clune says the robot's adaptability has already saved the research team's skin once -- though the stakes weren't as high as they'd be during a search and rescue operation. The study's lead authors, researchers at the Pierre and Marie Curie University in France, were asked to show the robot off for some visiting VIPs. They'd let the robot run its simulations and made sure it was working properly, but in the morning they were in for a nasty surprise: The university had waxed the floors of their lab in preparation for the demonstration.

"It made the place look spic and span, but obviously the robot could no longer walk," Clume said. "But luckily our robot can deal with unforeseen situations. It adapted from sliding around the room to walking steadily in minutes."

Come at me, bro. (Antoine Cully/UPMC)

Clune and his colleagues call their new algorithm "Intelligent Trial and Error."

[New algorithm could help ‘cheetah’ robot outrun humans soon]

"The robot doesn't ever understand the damage that's occurred," study author Jean-Baptiste Mouret of the Pierre and Marie Curie University said. "It just finds a behavior that works in spite of whatever is wrong. And we don't have to pre-compute different scenarios, where we say, 'here's how to walk with one leg missing'. We just let it explore its own body and find many ways to walk, and hope that one of these simulations will be useful when a limb is damaged. But we never have any idea how it will adapt."

Now the group will work on giving more complex robots access to the algorithm. In the future, they hope they can produce a useful robot -- one suited to dangerous rescue missions or home servitude -- with the same body savvy.

Want more science? Give these a click:

This mind-blowing new 3-D printing technique is inspired by ‘Terminator 2​’

This robot is using YouTube videos to learn all about us

Watch a human musician and his robots improvise together

This robot makes you feel like there’s a ghost behind you