Robots that learn to adapt