We simulated populations playing the iterated n-player public-goods game, proposing mutant strategies until reaching equilibrium, and then also proposing mutations to a player’s memory capacity m, each at rate μ/10. In these simulations all players initially have memory m = 1, with payoff parameters C = 1 and B = 1.2. Mutations to strategies were drawn uniformly from the full space of memory-m strategies. Mutations perturbing the memory m caused it to increase or decrease by 1, with a lower bound of m = 1. Evolution was modeled according to a copying process under weak mutation31 in a population of size N = 10 individuals. (a) When the group size is small, n = 2, defecting strategies are initially dominant in the population, but they are quickly replaced by cooperators as memory capacity evolves to higher values. (b) When group size is large, n = N = 10, defecting strategies initially dominate the population and they remain dominant as memory evolves. In both (a,b) the overall frequency of cooperators and defectors (that is, the fraction of robust cooperative (and defecting) strategies among all cooperative and (defecting) strategies) decline as the dimension of strategy space increases, in line with the decline in the overall volume of robust strategies (Fig. S4). (c) When the game size is small memory evolves rapidly to larger values, reflecting the greater success of longer-memory strategies at invading (Fig. S3), and driving the increase in cooperative as compared to defecting strategies. (d) When the group size is large memory does not evolve to large values, reaching only m = 2 across 50,000 generations, and reflecting the decline in long-memory strategies’ success as invaders in larger games. (e) As cooperation increases so does the average payoff of the population, by a factor of 5–10 fold. (f) The lack of increase in cooperation results in a much more modest (although still appreciable) increase in average payoff for the population as defectors become less frequent.