Learning when to Communicate at Scale in Multiagent Cooperative and Competitive Tasks