The power of cooperation in networks of learning agents