Learning to flock in open space by avoiding collisions and staying together