Researchers from the Sheffield Centre for Robotics programmed a group of 40 small robots which could organise themselves into a group and work together to solve simple tasks.
Swarming robots could eventually be shrunk to a microscopic size for use in medical procedures, because they require no memory and could function without a processor, experts said.
They could also be built to larger sizes and used in military or search-and-rescue operations which are too dangerous or inaccessible for people to venture into, or used in manufacturing to improve safety in industry.
The robots, which will be demonstrated at the Gadget Show Live in Birmingham this week, use a simple form of artificial intelligence to perform basic functions.
For example, when scattered at random across a room, they can arrange themselves into a group simply by each robot detecting whether there is another directly in front of it.
If any individual robot finds another in its path it turns around, and if the route is clear it begins moving outward in a spiral until it finds another robot. This eventually results in the whole group clumping together.
The robots are also able to arrange themselves into a particular order, for example by size, and to fetch objects by clustering around them and collectively pushing them in the same direction.
Dr Roderich Gross, who led the project, said: “We are developing artificial intelligence to control robots in a variety of ways. The key is to work out what is the minimum amount of information needed by the robot to accomplish its task.
By Nick Collins, Science Correspondent