The occasional absence of resources for cooperation and its role in the evolution of direct reciprocity