Researchers in the Sheffield Centre for Robotics have been working to program a group of 40 robots that 'swarm' together to carry out jobs. So far, they have demonstrated that the swarm can carry out simple fetching and carrying tasks, by grouping around an object and working together to push it across a surface.
The robots can also group themselves together into a single cluster after being scattered across a room, and organize themselves by order of priority. The programming for that part is simple. If the robots are being asked to group together, each robot only needs to be able to work out if there is another robot in front of it. If there is, it turns on the spot; if there isn't, it moves in a wider circle until it finds one.