We study the evolution of cooperation in the indefinitely repeated prisoner's dilemma when it is costly for players to adjust their strategy. Our experimental interface allows subjects to design a comprehensive strategy that then selects actions for them in every period. We conduct lab experiments in which subjects can adjust their strategies during a repeated game but may incur a cost for doing so. We find three main results. First, subjects learn to cooperate more when adjustments are costless than when they are costly. Second, subjects make more adjustments to their strategies when adjustments are costless, but they still make adjustments even when they are costly. Finally, we find that cooperative strategies emerge over time when adjustments are costless but not when adjustments are costly. These results highlight that within-game experimentation is critical to the rise of cooperative behavior. We provide simulations based on an evolutionary algorithm to support these results.