Abstract

Ulam’s spiral reveals patterns in the prime numbers by presenting positive integers in a right-angled whorl. The classic spatial prisoner’s dilemma (PD) reveals pathways to cooperation by presenting a model of agents interacting on a grid. This paper brings these tools together via a deterministic spatial PD model that distributes cooperators at the prime-numbered locations of Ulam’s spiral. The model focuses on a narrow boundary game variant of the PD for ease of comparison with early studies of the spatial PD. Despite constituting an initially small portion of the population, cooperators arranged in Ulam’s spiral always grow to dominance when (i) the payoff to free-riding is less than or equal to 8/6 (≈1.33) times the payoff to mutual cooperation and (ii) grid size equals or exceeds 23 × 23. As in any spatial PD model, particular formations of cooperators spur this growth and here these formations draw attention to rare configurations in Ulam’s spiral.

1. Introduction

Recent research verifies a long-anticipated connection between the prime numbers and the evolution of cooperation [1]. When one-shot prisoner dilemma games occur across intragenerational time points, cooperators can succeed via cyclical strategies with prime-numbered period lengths [2, 3]. This recent research indicates a role for prime numbers in the evolution of cooperation when models highlight the temporal aspect of social interaction, but what role might primes play when models highlight the spatial aspect of sociality? A deep literature has shown that spatial relations—including extraindividual connections and higher-order interactions depicted by hypergraphs [4]—can bring about cooperation’s evolution either in concert with other mechanisms [514] or independent of other mechanisms [1528]. This paper adds to the latter literature by showing that seeding the spatial prisoner’s dilemma with a particular representation of the primes can cultivate the evolution of cooperation because that representation includes formations of cooperators known to promote cooperation’s success on a spatial grid. Specifically, the study distributes cooperators at the prime-numbered locations of Ulam’s spiral [29] in a deterministic two-dimensional spatial prisoner’s dilemma model [16, 17] in which the prisoner’s dilemma takes the narrow form of the boundary game [30], and it finds that this initial seeding leads to the growth and dominance of cooperation when the payoff to free-riding is less than or equal to 8/6 (≈1.33) times the payoff to mutual cooperation and grid size equals or exceeds 23 × 23. Furthermore, the model highlights atypical configurations of the primes in Ulam’s spiral, thus shedding light on the spiral itself and, in so doing, contributing to research that uses life-science models to illuminate mathematical phenomena (e.g., [31]). These findings provide a very modest, first glimpse of how jointly studying Ulam’s spiral and the evolution of cooperation might offer insight into each of those enigmas.

Indeed, each enigma—Ulam’s spiral and the evolution of cooperation—continues to stoke curiosity. Ulam’s spiral, for one, has sparked many questions since its legendary emergence from the bored doodling of Stanislav M. Ulam [32]. During a dull talk, Ulam sketched the positive integers in a grid-like swirl and marked the primes [32]. Upon completion, Ulam’s drawing showed a subtle pattern among the primes. Their values ran in diagonal streaks and cross-hatched lines across the right-angled whorl [32]. The vague pattern became still more apparent when Ulam and colleagues computationally generated the spiral to ever larger values [29]. Though research has clarified aspects of the spiral’s properties, it remains a focus of ongoing inquiry [33, 34].

Likewise, despite extensive advances in the cross-disciplinary effort to understand it [3538], the evolution of cooperation has continued to enthrall the sciences because the realization of cooperation seems impossible yet empirical evidence suggests it is common [38, 39]. Cooperation, after all, requires entities to incur personal costs that benefit others, thus luring individuals to withhold cooperation while others engage in it; yet, this attempt to free-ride, when universally indulged, leaves all bemoaning that they and others had not chosen to cooperate [36, 37]. This seemingly impossible impasse materializes clearly in the dyadic prisoner’s dilemma in which two entities can both cooperate to earn R, but one-sided defection earns the higher payoff T and leaves a cooperator with the dismal payoff S, thus enticing joint defection and generating the middling payoff P [40]. This payoff structure (T > R > P > S) implies that evolutionary selection ought to favor those who attempt to free-ride; nonetheless, empirical evidence indicates that cooperation underlies innumerable examples of biological organization [38]. This paradoxical relation between theory and empirics arouses continued fascination with how cooperation evolved and, to date, researchers have uncovered many mechanisms—both active and passive—that trigger cooperation’s evolution [37, 39, 41, 42].

Active mechanisms include those in which cooperative individuals behave conditionally to avoid free-riding—for instance, by determining whether to cooperate based on others’ shared genes [43], reputations [4447], tags [48], or wealth [4951]. Such active mechanisms also include conditional behavior either to sanction defection (e.g., via punishment [14, 5259], reciprocating defection with defection [36, 60], or discontinuing play [6163]) or to repay cooperation (e.g., via reciprocal altruism and rewards [60, 64, 65]). An adjacent literature, moreover, has recently generalized from the problem of cooperation to consider moral preferences more widely [66] and offers a new active mechanism for study in the literature on cooperation. Specifically, it presents a novel mathematical model—applicable to the study of cooperation yet relevant to all social decisions—in which individuals gain utility based on the extent to which they care about and perceive an action to be morally correct [66], thus offering the fascinating possibility of formally accounting for moral evaluation of social cooperation based on personal norms [66] (a novel active mechanism), not just adherence to social norms [67, 68].

Mechanisms supporting cooperation also include passive mechanisms in which cooperation evolves due to properties of either an entity’s environment (e.g., its network of interactions [42, 6974] or the contribution of social interaction to fitness [75]) or its movement in that environment (e.g., due to dispersal patterns among kin [15, 7679] or features of movement [80, 81]). Recent research, furthermore, presents the possibility of developing a richer picture of such passive mechanisms by studying higher-order interactions via the modeling of cooperation on hypergraphs [4]. Allowing for connections between extraindividual entities such as groups or networks, this recent research opens the door to lines of inquiry that study multiple passive mechanisms in a single framework—a paradigm that is particularly valuable in investigations of cooperation in practical or policy settings [4]. Together, these mechanisms indicate the various ways that cooperation can evolve even without deliberate action. Although past work successfully unifies many of these mechanisms [26, 37], the breadth of possible mechanisms supporting cooperation remains unknown and the focus of ongoing inquiry.

This paper adds to that avenue of research via a model that shows how Ulam’s spiral and the evolution of cooperation can shed light on each other. Studying the model reveals the conditions in which locating cooperators at the prime-number values of Ulam’s spiral can serve as a mechanism to spur cooperation’s evolution. That is, to be clear, past research shows that cooperation’s evolution in the spatial PD model can result even from random allocations of cooperators arranged in configurations that insulate them from defectors and allow them to earn higher payoffs [19, 25]. Do such configurations occur in Ulam’s spiral, thus making it a starting point for cooperation to emerge? Albeit only one of myriad ways to arrange cooperators at the outset of a spatial PD model, Ulam’s spiral is a theoretically interesting configuration due to the significance of the prime numbers and the possibility that the spiral might emerge naturally through a rotating sieve process. As a result, this paper considers a spatial PD model that assesses whether distributing cooperators at the prime-number locations of Ulam’s spiral yields configurations of cooperators that promote cooperation’s evolution. Indeed, the research finds that, under certain parameter settings, Ulam’s spiral does contain formations that facilitate cooperation’s evolution. Such inquiry also indicates how the sources of cooperators’ growth in the model highlight atypical configurations of the primes in the spiral. These findings hint at how researchers might use the model to further study both cooperation’s evolution and the prime numbers.

2. Methods

The model studies a population dispersed across an grid with periodic boundaries. Each member of the population resides in its own grid cell (i.e. population size, ) and adopts a strategy either to cooperate () or defect () in all of its interactions (cf. [8284], which present more-nuanced depictions of how the decision to cooperate or defect might be modeled). Interactions occur across generations, , where . Specifically, members of the population interact once per generation with each individual residing in their Moore neighborhood—that is, with the individuals located at each of their eight adjacent cells whose relative location can be described using the cardinal directions (North, East, South, and West) and the intercardinal directions (Northeast, Southeast, Southwest, and Northwest). Albeit less sophisticated and realistic than alternative spatial structures, the model’s square lattice and attendant interaction network continue to receive attention in current research [84] and this paper uses them for ease of comparison with the existing literature. Future work might extend the present model to consider alternative neighborhoods and interaction ranges (as in [85]).

Interactions consist of one-shot prisoner’s dilemma games that use the payoff matrix from the classic study of Nowak and May [17].

This version of the prisoner’s dilemma sets the payoff to mutual cooperation, , and the payoff to exploitation, , while remunerating defectors who free-ride with and paying defectors who mutually defect with , which is set at in the simulation reported here. The model in (1) constitutes a version of the boundary game—a specific subclass of the prisoner’s dilemma that exhibits properties akin to the game of chicken and does not capture the full richness of other parameterizations of the PD, such as the donor-recipient game, which make the dilemma at the heart of the prisoner’s dilemma more vexing [30, 8688]. Accordingly, by using (1) to depict the PD, this study trades generality and robustness for ease of comparing the results of this investigation with those of early studies of the spatial PD [19, 20].

The payoffs that a member of the population earns from its interactions with each neighbor are then summed. This individual, subsequently, compares its summed payoffs to the summed payoffs of each of its neighbors and it switches to a new strategy if one of its neighbors’ earned more using that strategy. It keeps its strategy if it earned more than its neighbors or if a neighbor using its same strategy earned more. Accordingly, the model uses the original strategy update method of the spatial prisoner’s dilemma [17] instead of more-recent novel conceptualizations of the update dynamics [8991].

The model’s sequence of social interaction, payoff summation, payoff comparison, and strategy adoption repeats across generations until either the population reaches a stable state (i.e. all members of the population employ the same strategy in that they used in ) or until the maximum number of generations, , is reached. The study sets as test runs of the simulation indicated that the population always reached a constant state (i.e. a static equilibrium) or a repeating pattern (i.e. a stable limit cycle) well before the 200th generation.

The model begins with cooperators located at the prime-numbered values of Ulam’s spiral, while defectors are located at composite values of Ulam’s spiral. Given evidence that the initial fraction of cooperators [92] and the spatial pattern of cooperators [93] influence the evolution of cooperation in the spatial prisoner’s dilemma, it warrants mentioning that seeding the model with cooperators at the prime-number locations of Ulam’s spiral results in a constant fraction and fixed pattern of cooperators (at ) for any given value of .

Numerical simulations examine the model at , , and , as well as at small odd-number population sizes ranging from to , which allow for identification of the minimal value of at which selection for cooperation occurs when cooperators are arranged at the prime-number locations of Ulam’s spiral. Note that only takes odd values so that the grid possesses a central cell (horizontal and vertical midpoint) that can serve as the origin of Ulam’s spiral. Simulations also vary the value of from to , in -unit increments, so as to explore the critical values of that research has identified as influencing dynamics in the spatial prisoner’s dilemma (viz. [94], p.148).

The simulation was implemented and analyzed using the programming language R [95], with the core of the program drawing on existing code for developing cellular automata models in R [96]. All computer code is available publicly via links in the supplementary materials of this paper, as is the output data reported in the results.

3. Results

Simulation results indicate clear conditions in which cooperators can grow to dominance when initially distributed at the prime-numbered locations of Ulam’s spiral. As indicated in Figure 1, varying grid size, , across low values ranging from 3 to 51 reveals that cooperation never comes to dominate the population when . For , the value of constrains the growth of cooperators (see Figure 1): in runs when , cooperators always go extinct in the simulation, whereas in runs when and , cooperators always grow their share of the population until it vastly exceeds the proportion of defectors (Figure 1). When and , cooperators always constitute at least 96.54% of the population at the end of the simulation. Likewise, under those same values of , when cooperators always constitute at least 97.65% of the population and when cooperators never constitute less than 98.18% of the population.

When cooperator extinction occurs, it always occurs rapidly (viz., by ), whereas cooperator growth transpires over more generations and follows a common pattern early in a run. First, the population of cooperators initially retreats as cooperators who lack a sufficient number of cooperative neighbors switch their strategy to locally profitable defector strategies. For instance, Figure 2 shows an example run with and , which depicts this retreat from the first generation (panel Figure 2(a)) to the second generation (panel Figure 2(b)). When , the proportion of the population consisting of cooperators declines from a median proportion of at to a median proportion of at before rebounding to a median proportion of cooperators of at , and growing thereafter. When takes values of , , and , the proportion of cooperators from generation 1 to generation 2 declines from, respectively, to , to , and to . Following this collapse, a sustained uptick in cooperators occurs as clusters of cooperators outcompete their neighboring defectors (see example run in Figure 2, panels Figure 2(c) and 2(d)). This rebound continues until cooperators grow to dominance.

The population of cooperators recovers due to clusters of cooperators—an expected phenomenon given that past research has shown that such clusters promote cooperation in the spatial prisoner’s dilemma [94]. In the present model, those clusters form at a small number of regions of Ulam’s spiral where prime numbers are arranged in an “X” shaped pattern that fits within a square and adjacent primes extend from one or more of the X-shape’s arms into a region devoid of other primes (see Figure 3). When , clusters of cooperators form in four regions of the grid and the clusters center, respectively, on the prime numbers , , , and . When , the same four clusters lead to cooperation’s dominance and a fifth, additional cluster appears centered on the prime number . Two further clusters augment those same five clusters when ; the prime numbers and reside at the heart of these new, additional clusters. Figure 3 displays the location of all of these clusters on a grid by overlaying a snapshot of the simulation when on a snapshot of the simulation when (in a run where and ).

When cooperators grow from these clusters (i.e. when and ), the population often exhibits polymorphism with cooperators constituting the vast majority of the population; model parameters determine whether the polymorphic population enters a static configuration or a repeating pattern. The panels of Figure 4 give general insight into the population’s final states by displaying snapshots of the final generation of the simulation for , , and (columns of the figure), and the values of (rows of the figure) that past research has shown to be influential in the spatial prisoner’s dilemma’s dynamics [94]. Animations of the complete runs from which these snapshots were derived are contained in the supplementary material files (Supplementary Material Files, Animations (a)–(o)). As evident in the panels of Figure 4, broad visual similarities in the final population state appear for each value of across population sizes (i.e. similarities appear within rows of the figure).

When (Figure 4, Panels Figures 4(a)–4(c)), the population exhibits asymmetric, thin veins of defectors. For (Figure 4, Panels Figures 4(d)–4(f)), the diagonals of defectors that appear prominently in panels Figures 4(a)–4(c) of Figure 4 no longer emerge. The population reaches a stable limit cycle in which defectors persist on slender vertical and horizontal lines; these lines are capped with rectangles that appear then disappear in a two-period oscillation (Supplementary Material Files, Animations (d)–(f)). For the parameter settings (Figures 4(g)–4(i)), (Figures 4(j)–4(l)), and (Figures 4(m)–4(o)), the population exhibits peculiar repeating patterns in which cooperators perpetually stifle defectors’ attempted advances, except for the sole case of and , which ends in a static population state (Figure 4(m); Supplementary Material Files, Animations (m)). The states of the population displayed in panels (m)–(o) also appear when (Supplementary Material Files, Animations (p)–(r)). These intricate patterns of the polymorphic population disappear with , which results in a uniformly tinted grid indicative of a population consisting entirely of defectors. Thus, cooperation grows from Ulam’s spiral only in a portion of the parameter space; but, when it does grow, it often yields asymmetric, intriguing visuals.

4. Discussion and Conclusion

This paper has reported a simulation of the spatial prisoner’s dilemma model that initially distributes cooperators at the prime-valued locations of Ulam’s spiral. Its results provide a first glimpse of how future researchers might use the model to understand further features of the primes and the evolution of cooperation. The results show that, despite constituting a small portion of the population, cooperators distributed at the primes in Ulam’s spiral grow to dominance when and . At a fundamental level, this growth occurs due to configurations of cooperators on the grid that impede exploitation and allow cooperators to thrive [25, 94]; accordingly, this paper simply shows that such configurations exist within Ulam’s spiral, thus making it one of many starting points for the evolution of cooperation, albeit a salient starting point due to its connection to the primes. Furthermore, in runs where cooperators take over, cooperators’ rise to dominance follows a preliminary collapse that is overcome by a small number of cooperative clusters; the location of these cooperative clusters imply unique configurations in Ulam’s spiral and, to my knowledge, these particular regions of Ulam’s spiral have not received previous attention. The present research thus follows in the path of previous work that seeks to use life-science models to gain insight into mathematical problems (e.g., [31]).

The present research also provides a basis for future work to consider whether nondeliberate processes can produce Ulam’s spiral, thus providing an assessment of whether an allocation of cooperators in the fashion depicted in this paper is empirically plausible. Past research has shown how physical [97, 98], biological [1, 99107], and social phenomena [2, 3] can draw attention to the prime numbers and foundational studies in this avenue of research have considered how prime-generating patterns might influence the spatial organization of entities [1]. The present paper underscores the importance of such work and it calls for further investigation into how or whether Ulam’s spiral can emerge in reality—not just on the theoretician’s page—as a spatial distribution of organisms capable of stimulating cooperation. Furthermore, future research on this subject should study the model under a version of the PD that exhibits a stronger dilemma than that of the boundary game, which the PD in this study resembles [30, 8688]. The current results, although easy to compare with early studies of the spatial PD, lack general applicability due to the version of the PD used in this study and future work should address this limitation. Finally, a legitimate criticism of the current work is that it is mere theoretical musing: a curiosity without a strong scientific rationale. Whether future research can build on the present work ultimately will determine the severity of the critique. By showing what happens when seeding the spatial prisoner’s dilemma with Ulam’s spiral, this paper hopefully has prepared ground for such work.

Data Availability

All computer code and data used in the research reported here are publicly available via hyperlinks in the supplementary materials. The same computer code and data also can be accessed via the following permanent archive: https://osf.io/gkqja/?view_only=18fe1fcdde7c4730b43e96caf3acd072.

Conflicts of Interest

The authors declare that they have no conflicts of interest.

Supplementary Materials

To facilitate replication and further exploration of the results reported in the main text of this manuscript, I have submitted supplementary material files with this manuscript. The supplementary material files contain hyperlinks that provide access to the computer code and data sets underlying the findings reported in the main text, plus they include animations of simulation runs reported in the main text of the manuscript. (Supplementary Materials)