Greedy AI Agents Learn to Cooperate