Flocking behaviour in Stage (3.2.2) can be realised by using 'pioneer_flocking' Stage controller. The default settings simulates 100 robots which exhibit swarm behaviour by forming flocks.
A interesting feature of a swarm is that it can 'capture' other robots in its path. The captured robots behave as a part of the swarm.
A DEMONSTRATION
1/3 - Initially there are 100 red robots and 3 yellow robots. On starting simulation the red robots start to move, triggered by sonars bouncing off the wall, while the yellow robots are stationary.
2/3 - The red swarm on reaching the yellow robots 'capture' them.
3/3 - The captured yellow robots behave as a part of the swarm.
Gazebo is a part of the Player Project. It is a 3D simulator utilising ODE and OGRE. ROS has incorporated Gazebo into their distributions with some minor modification.
GAZEBO@ROS WITH WORLD FILES - A DETOUR FROM THE USUAL
Gazebo, while it is a part of Player Project is used with world files. However, ROS recommend using Gazebo with launch files - these launch files identify the corresponding world file.
However in the spirit of Player/Stage/Gazebo it is possible to run Gazebo with world files from its executable, located at/opt/ros/diamondback/stacks/simulator_gazebo/gazebo/bin .
Thus using ./gazebo with pioneer2dx.world, which is a well known Player Project world file;
Start an instance of roscore - gazebo is built with slight modification, so an instance of master (roscore) is needed. The later scripts search for the master.
Navigate to the gazebo executables directory ( cd /opt/ros/diamondback/stacks/simulator_gazebo/gazebo/bin)
Start Gazebo with pioneer2dx.world file (./gazebo /path/to/pioneer2dx.world)
The following window should pop up,
Trying the rxgraph to check the ROS nodes at work;
Trying with pioneer2at.world file;
The same works for Stage, the executables at /opt/ros/diamondback/stacks/simulator_stage/stage/bin can be used in a similar manner. The executables, stage and stageros work same with a world file giving 2D simulations. However stage is the primitive Player Project executable and doesn't need a roscore master while stageros is more 'ROS like', needs roscore and works with ROS nodes.
NOTE
Tested on ROS 1.4.9 Diamondback (Gazebo 0.10.0 and Stage 3.2.2)
pioneer2dx.world and pioneer2at.world files can be found in Gazebo installation files (viz. gazebo-0.10.0/worlds)
An alternative is to use, rosrun gazebo gazebo /path/to/pioneer2dx.world file