Grammar-based cooperative learning for evolving collective behaviours in multi-agent systems