Scientists have created robotic ants that, like the real ones, work together to complete tasks and protect themselves from danger.