A Bottom-Up Approach to the Evolution of Swarming