Reinforcement learning facilitates an optimal interaction intensity for cooperation