We study the evolution of behavior in iterated n-player public-goods games in which players use strategies with memory capacity m. We consider a replicating population of N individuals who each receive a payoff from engaging in an infinitely iterated game with all possible subsets of (n − 1) opponents in the population. Players then reproduce according to a “copying process”, in which a player X copies another player’s strategy Y with a probability where SX and SY are the player’s respective payoffs and s scales the strength of selection. We consider the case of strong selection, such that a rare mutant who is at a selective disadvantage is quickly lost from the population31. We investigate the success of cooperative strategies as a function of group size and the length of players’ memories. We determine the frequency of robust cooperative strategies, which can resist invasion by any possible mutant. (Top) Depending on the size of the game n relative to the population N, the dynamics of public-goods games are different. In a two-player game, a series of pairwise interactions occur in the population at each generation (left). If the whole population plays the game each generation (right) all players interact simultaneously. (Bottom) Memory of past events results in strategies that update behavior depending on the histories of both players’ actions. This allows for more complex strategies, such as those that punish rare defection or reward rare cooperation.