NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it was made in a version prior to NetLogo 6.0, which NetLogo Web requires.)


LogoMoth models allow users to simulate an iterated prisoner’s dilemma game (see's_dilemma) in which preprogrammed strategies interact with each other by either cooperating or defecting and/or staying or leaving. LogoMoth is modified from the traditional model in two important ways: First, individuals may, depending on their strategy, choose to leave their partner. Second, leaving and being left (i.e., staying) may incur a “cost”.

The purpose of these modifications is to suggest alternative explanations for animal and human social behavior masked by the rules of traditional Iterated PD games (JOYCE, ET AL. 2006). Traditional Iterated PD games operate on the assumption that two players are "stuck" with one another through a series of interactions; under that constraint, the strategy that has done famously well is TFT, a strategy that cooperates on the first game of the match and then imitates its opponent's previous move in every subsequent. (AXELROD, (1984), The success of TFT in PD games has made it the model for hundreds of explanations of "reciprocity" in animal and human social relations (notably, COSMIDES AND TOOBY, 1992; WILKINSON, 1984).

This focus on TFT reciprocity as a key to animal sociality may be unfounded. The structure of the Axelrod game constrains the players to remain paired, even in non-productive partnership. This constraint is highly un-natural in animal (and human) social systems where individuals typically break off relationships if a partnership is not productive. In mapping TFT reciprocity on to natural social systems, theorists have implicitly recognized this artificiality in the tournament structure when they have interpreted TFT as requiring a considerable level of cognitive complexity: instead of being bound to one another as the tournament structure demands, partners must recognize one another and remember what they did on the previous occasion. A simpler ... and therefore more universal... basis for social clustering would be one in which social agents are programmed to attach themselves to agents who benefit them. In the language of the PD literature, such an agent would respond to defection by breaking up a partnership and looking for another partner amongst other unattached agents. Far from requiring recognition, such a strategy would require only simple movement away from an aversive condition. We call this strategy, "My-way Or The Highway", abbreviated MOTH.


A LogoMoth simulation starts by creating the specified number of players (turtles) using each strategy, which then play a series of PD games. The games are divided into matches (games per match), with “reproduction” occurring between matches until the simulation is over (matches per sim). At the start of every match each player is partnered to another player at random. According to their strategies, LogoMoth agents make two sorts of decisions: First, when they play a game they either cooperate with their partner or defect (Cooperate = 1 or 0). Second, after the game they either continue to play with a particular partner in the next game or dissolve the partnership (Stay = 1 or 0). If either member of a partnership dissolves it, and both players return to the pool of un-partnered players to be randomly re-partnered for the next game of the match. Strategies can be conditional or non-conditional in that an agent may or may not use the behavior of its partner on the previous game to decide what to do on the next. Users of the program can pick among any combination of six strategies. (An earlier version of the program offered two additional strategies but these proved to be irrelevant and have been dropped.)

The first three strategies will be familiar to any reader of Axelrod and Hamilton's Evolution of Cooperation. The second three all make use of leaving in some way. MOTH is the one that most closely resembles what we think animals are likely to do in most failed cooperation situations. The rest are chosen to exploit various perceived weaknesses of the other strategies, but are exhaustive only in the sense that these are the ones we could think of. One of our goals in getting LogoMoth into circulation is to encourage others to think of better challengers.

LogoMoth is an evolutionary program, i.e., it is designed to simulate the Darwinian competition between organisms seeking to out-reproduce one another in a population whose numbers are arbitrarily forced to remain stable throughout each simulation. Consequently, at the end of each match of N games, the number of points scored by the players of each strategy is summed and divided by the number of players of that strategy to determine the proportion of points won by each strategy. These proportions determine the number of Players allocated to each strategy in the next match.

Since the population was always capped at a constant after each match, remainders were inevitable and had to be distributed as additional players to some of the strategies and not to others.

This distribution was one of the details in which the devil was found. By the time we had gotten done thinking about this distribution process, we had come up with five different ways of doing it. The method chosen privileged the most successful strategies. We simply assigned the extra players so that those strategies with the best records in the previous match were most likely to receive the extra players. Readers interested in the other methods we considered are encouraged to contact Owen Densmore as for details.


LogoMoth is a research program designed to accommodate many sorts of curiosity about the relation between the idea of conditional altruism and the idea of conditional leaving. You can manipulate many features of the game, the players, the matches, and the simulation AND you can save your experiments using NetLogo's behavior space.

Payoff Space

As in the standard prisoner's dilemma game, LogoMoth is based on the idea that two players play against one another for payoffs which depend on what the two players do. Their two choices are to cooperate (C) or defect (D)-- i.e., to be an altruist or selfish. This conceptualization produces four cells, which for simplicity sake, we will always identify here in their "reading" order: i.e., Top Left (Cc), Top Right (Cd) , Bottom Left (Dc), and Bottom right (Dd). The payoffs in each cell always represent the payoff to the left marginal player, playing one of two strategies, against the top marginal player, playing the same two strategies. Thus, the standard Prisoners’ Dilemma game, in which a cooperator receives 3 playing against another cooperator, 0 playing against a defector, while a defector receives 5 playing against a defector and 1 playing against another defector, will be represented here as a 3,0,5,1 game.

Each combination of cell payoffs yields a different game-type, and the possibilities are, of course, infinite. Although you can choose any combination of payoffs you like, LogoMoth features three particular examples. One is the standard PD game, 3,0,5,1. PD games, by definition are those whose payoffs follow the rules, Dc>Cc>Dd>Cd and 2Cc > Cd + Dc. Another game of interest to us, we call the altruist game in which the payoffs must be consistent with b-c, -c, b, 0, where b>c>0. Some PD games meet the criteria for altruist games -- 3, -2, 5, 0, for instance-- and LogoMoth features this choice as well. But a PD game need not be an altruist game.

For modeling purposes, minus numbers supply additional conceptual devils, and so we offer what we call a AG+ game, in which a constant has been added to each cell to dispense with negative numbers: 5, 0, 7, 2. The AG+ game is a PD game, but it is not strictly speaking an altruist game. However, the differences between the payoffs of the 4 cells are preserved, and we have found no computation that we are in the habit of performing with AG games that is affected by the difference.

Different Combinations of Strategies.

You may choose any combination of strategies by "zeroing out" strategies that DON’T interest you. Using the same sliders, you can also test whether a strategy is robust against invasion by giving it many players and introducing the other strategies, in small numbers, one by one. Or you can see which strategy is a good invader by holding the numbers of players of other strategies at maximum and introducing small numbers of different invaders, one by one.

Number of Games in a Match.

Because cooperators who stay together accumulate benefits for themselves AND deny defectors the benefits of defecting, the number of games in a match proves to be a powerful variable in LogoMoth play. You can evaluate the impact of the number of games in a match and the number of matches in a simulation by moving the sliders provided.

Cost to Leaver/Cost to Stayer

Early reviewers of this project, some of whom we suspect were the victims of ugly divorces, worried that it was unrealistic for MOTH strategists to be able to get a way scot-free from a first-game defector. Wouldn’t first-game defectors be selected for inflicting a cost on MOTH for leaving? And couldn’t the infliction of that cost itself entail a cost?. Consequently, we added sliders to permit the examination of the consequences of partner separations. These consequences can be either costs or benefits and can be imposed on either or both members of a partnership. Consequences are imposed when one partner opts to leave and the other partner opts to stay. When a partnership is dissolved, the player that stays receives the Stayer consequence and the player that leaves receives the Leaver consequence; if both partners opt to leave then neither player receives a consequence.

In the present version, the decision was made to impose the Leaver and Stayer Cost only when MOTH left because, of the conditional associates, only partnerships with MOTH allow first-defectors earn the maximum score. Given the benefit of maintaining a partnership with MOTH it is likely that a first-defector will evolve a mechanism to deter MOTH from leaving—implemented as the Leaver Cost. Since, however, it is unlikely that inflicting a cost to MOTH will be of no consequence to the Stayer, a Stayer Cost may be assessed to reflect the cost borne by the player for punishing MOTH.


Notice first whether the model replicates the traditional Axelrod results. Reassurance on this point can be sought by zeroing out those strategies that were not in the original Axelrod Tournament. Under these circumstances, TFT in LogoMoth is a robust competitor, although it sometimes fails against ALLC and ALLD.

Then check out MOTH's ability as a competitor. Look first at how well moth does against TFT's original competitors. The short answer is "better", It wins more often than TFT, and it usually wins quicker. Now take a look at Moth's competition against all three Axelrod strategies, ALLC, ALLD, and TFT. You will find that as long as matches are reasonably long, MOTH always predominates in simulations containing all of the other Axelrod strategies. If matches are short -- less than 10 games per match -- the result begins to be much more unpredictable. Finally examine how MOTH does against all 5 other strategies. Once again, if matches are reasonably long it almost always predominates. However it rarely excludes all other competitors. A typical result is that MOTH and either ALLC or TFT are left standing at the end of the simulation.

Another fascinating project is locating tipping points. A match size of 7 seems to be an important tipping point. We also think that important tipping points will be found in changes in the payoff matrix
Finally, check out the consequences of inflicting costs on stayers and leavers. Lower Leaver Costs favor MOTH in its competition with other first-game cooperators but hurt first-cooperators in their competition with first-game defectors.



AXELROD R (1984) The Evolution of Cooperation. New York: Basic Books.
COSMIDES L and Tooby J (1992), “Cognitive adaptations for social exchange”. In Barkow J H, Cosmides L and Tooby J. (Eds.), The Adapted Mind: Evolutionary Psychology and the Generation of Culture. New York: Oxford.)
JOYCE, David, Kennison, John, Densmore, Owen, Guerin, Steven, Barr, Shawn, Charles, Eric and et al. (2006). 'My Way or the Highway: a More Naturalistic Model of Altruism Tested in an Iterative Prisoners' Dilemma'. Journal of Artificial Societies and Social Simulation 9(2) <>.
WILKINSON G S (1984) Reciprocal Food Sharing in the Vampire Bat. Nature, Issue 308. pp. 181-184.


LogoMoth is a "docking" of an earlier java program (The Battle Applet), one of a series of applications of the MOTH idea that were created by David Joyce of Clark University's Math and Computer Science, with advice and consultation from John Kennison and Nicholas Thompson. Readers who found LogoMoth interesting are strongly encouraged to have a look at the whole series of applets, which may be found at:

We also owe a tremendous debt of thanks to the members of the Santa Fe Applied Complexity Group (“FRIAM”), in particular to Carl Tollander and Frank Wimberly.

• Shawn Barr and Eric Charles
– Program in Social, Evolutionary, and Cultural Psychology,
– Department of Psychology
– Clark University,
– Worcester MA, 01610.

• Owen Densmore* and Stephen Guerin*
– Redfish Group and Friam Applied Complexity Group
– 843 Agua Fria Road.
– Santa Fe, NM, 87501
– Owen or Stephen, @

• Nick Thompson*
– Program in Social, Evolutionary, and Cultural Psychology,
– Departments of Biology and Psychology
– Clark University,
– Worcester MA, 01610.

(back to the NetLogo User Community Models)