Algorithm gives robots an instinctive understanding of how to use tools