Prejudice is a human attitude involving generally negative and unsubstantiated prejudgement of others. When acted upon, this results in wide-ranging behaviours such as sexism, ageism and discrimination against sexual preference1,2,3 through to ethnic, racial, nationalistic and religious extremism4,5, with bias and intergroup conflict characterised as a “problem of the century”6. Most recently, prejudice has been highlighted in connection to global political events: for example anti-immigration prejudice was a strong correlate of support for Brexit7.

The human disposition to categorize others through their group identity creates an opportunity for discrimination8,9,10. As a consequence of in-group formation11, which occurs through cultural or biological identification with others, or as a consequence of identity-less strangers mutually cooperating12, bias can take hold in two ways. Through in-group favoritism13,14,15,16, people prefer to help fellow group members, while out-group prejudice6,17,18 represents hostility to those beyond the in-group. These phenomena are easily triggered in human subjects under a wide range of transient experimental conditions8,13,16,19. This has contributed to a misperception that positive discrimination to the in-group and negative discrimination to the out-group are inevitable20.

Confusion arises between out-group prejudice and in-group favoritism because both concepts potentially reinforce the in-group, but as a consequence of different psychological mechanisms. While in-group favoritism is based on mutual attraction, out-group prejudice discounts the out-group by negatively accentuating differences. In-group favoritism does not depend on negatively biased attitudes, where as prejudice does. From a psychological perspective, this renders in-group favoritism insufficient to model prejudice. Consequently, understanding the separate roles of in-group and out-group discrimination is socially important6. In-group favoritism has received significant attention, but the evolution of out-group prejudice has received a more limited explicit focus.

Evolutionary game theory provides a powerful framework to examine the dynamics that can promote discriminatory behaviour14,15,21,22,23,24,25. In particular, tag based models15,26,27,28,29,30,31,32,33,34 have shown that spontaneous cooperation can emerge from an agent’s donation being related to whether the recipient’s ‘tag’ is sufficiently similar to their own. Tags are arbitrary symbols upon which discrimination can be made, which must propagate with a behavioral strategy for cooperation to emerge. Groups of individuals can be defined through common tags where the model allows (e.g.15). This has established insights into in-group favoritism, particularly that the ability to discriminate between the in-group and out-group can actually promote cooperation, helping to explain why a predisposition toward in-group favoritism have evolved and can be easily triggered15.

Beyond tags, alternative models for studying the evolution of in-group favoritism are limited. Fu et al.14 provide an alternative generalised approach based on evolutionary set theory11 that permits out-group as well as in-group interactions. Tag based models generally prohibit this, other than in33,34 where although explicit groups are not defined, the model allows individual probabilities of cooperation with dis-similar others to evolve. Fu et al.14 allow agents to move between sets, with successful sets attracting members and successful strategies gaining imitators. Agents can also differentiate between in-group and out-group strategies and conditions are determined under which preferential in-group cooperation is favoured by selection.

A further relevant consideration is so-called parochial altruism35,36,37,38,39, where out-group discrimination has mainly been examined under coevolution with in-group favoritism. Both these costly discriminatory behaviours have been proposed as necessary for success in warfare35, possibly promoting their coevolution36. Parochial altruism is also observed as deeply embedded in human group behaviour37,39, although further clarification is needed on the analysis of the selective mechanisms at work in current models38.

While prejudice is common, its manifestation is fluid, indicating that culture and cultural evolution40 must play an important role in the evolution of bias, through socially transmitted beliefs that help to create and sustain groups. In previous related models, we note that discrimination is considered independently from a group’s identity. Typically, groups of individuals are modelled as a consequence of a common arbitrary tag, and evolution acts upon the agent’s discriminatory strategy in association with that tag. However humans have the capacity to directly identify with a discriminatory attitude as a phenotypic tag in its own right. As such, a discriminatory attitude towards the out-group can provide a common defining feature for a group. In other words, prejudicial (or non-prejudicial) views can act to bind a group and define its boundary. We note that prejudicial feelings towards other groups have been predicted as a consequence of the perceived threat that they pose41. Also, at the extremes of group identity, common out-group prejudicial attitudes, from within a larger population, are a particular feature of homophilic attraction and group identity (e.g.42,43).

Accordingly, in this paper we introduce and study the evolution of a new abstract class of group, the prejudicial group, defined by the common prejudicial disposition of its members towards the out-group. We assume that a population of agents is composed of sub-populations, each denoted SP t , where the agents in SP t have the common immutable trait t. A prejudicial group \({G}_{t,\alpha }\) within a sub-population SP t represents the maximal subset of agents with a common prejudicial attitude (α) to the out-group. We use i to index the particular parameter values held by an agent i, with t i indicating i’s trait and α i indicating i’s prejudice level. Therefore t i = t and α i = α if and only if agent i is a member of G t,α . An out-group member is any agent not carrying both the prejudicial attitude value α and trait t. This arrangement gives a simple representation of features such as nationalism, or political, ideological, religious or extremist convictions within a sub-population. People who are less favourable to one out-group tend to be less favourable to other out-groups44, and therefore we do not distinguish between them: an agent’s prejudice level α i is equally applied to all out-groups. The groups \({G}_{t,\alpha }\) partition the sub-population SP t , so that every agent belongs to precisely one group. For experimental purposes we assume α ∈ {0, 0.25, 0.5, 0.75, 1}.

Our aim is to observe how α i evolves with cooperation, and to further understand the conditions that promote or impede α i . We seek to achieve this in a context aligned with observed human behaviour. Across all species, only humans fully engage with indirect reciprocity23,45 making it an appropriate cooperative scenario to consider46. Indirect reciprocity is commonly examined using the donation game, a special case of the mutual aid game47, where agents choose whether or not to donate at cost c to a recipient who gains benefit b > c > 0, without the guarantee of future reciprocation.

Strategies for indirect reciprocity are generally driven by reputation46,48, which acts as a currency to judge third party agents who may never be encountered again. While a range of evolutionary approaches to sustaining indirect reciprocity are known22,46,49,50, the social comparison of reputation between a donor and the recipient has recently been developed25, where the heuristic of donating to those with similar or higher reputation evolves to sustain cooperation. This is of high relevance to prejudice because social comparison is a widespread human disposition51,52,53,54,55 that plays a fundamental role in categorization8,9,10 and subsequent stereotyping18. Therefore we extend this model25 to incorporate prejudicial attitudes against out-group agents, allowing agents to discount the reputation of out-group members by a factor of α i when considering whether or not to donate.

The model we develop involves 100 agents, which are randomly selected to play the donation game 5000 times, and which constitutes one generation, before evolution of the agents’ strategy. Reputation is central to the model, and assessment rules are applied to update a donating agent’s reputation in light of their donation behavior immediately after each donation game. Assessment rules represent social norms, which humans are well-disposed to internalising and perpetuating56,57,58. These enable the judgement of reward and penalty, which are a basis for modelling morality59. Because prejudicial groups are defined by the common out-group prejudicial disposition of their members, it is appropriate to model an in-group reputation for each agent i, denoted \({r}_{i}^{G}\), as well as a universal reputation for agent i, denoted \({r}_{i}^{U}\), which is the hypothetical reputation in the absence of any prejudice or groups. This approach applies social norms both locally and globally.

Wide-ranging assessment rules have been previously studied22,60,61,62,63,64, however standing62, with its origins in the work of Sugden60, has emerged as one of the dominant approaches because it permits “legitimate shirking”. Here, an agent’s reputation is not reduced when there is a justified basis for defection (e.g., the potential recipient is a defector). We apply a generalised form of standing for both in-group and universal reputations, where a reputation is permitted to range between −5 and +5 in unit steps, as employed in49. This choice is based on the analysis conducted in25, where the moral conventions of judging, image scoring and standing were compared, allowing evolution to act upon all possible social comparison action rules. These results indicated that either standing or judging are preferential rules, and this comes from their ability to ensure those agents who are limited in their cooperation are not rewarded.

Both the in-group and universal reputations are conceptually simple but require a number of criteria to update them in light of the donation or defection behaviour by an agent i. Both types of reputation follow the principles of standing. Specifically, \({r}_{i}^{U}\) and \({r}_{i}^{G}\) are incremented when the donor i cooperates. For the universal reputation, if agent i defects on agent j, whose reputation is of relatively low standing (i.e., \({r}_{j}^{U}\) is lesser than \({r}_{i}^{U}\)), then this is deemed legitimate and i suffers no penalty to its reputation (i.e., \({r}_{i}^{U}\) remains unchanged). However if i defects on agent j and this isn’t deemed legitimate (i.e., \({r}_{j}^{U}\) is the same or greater than \({r}_{i}^{U}\)) then i’s universal reputation is decremented.

Concerning in-group reputation, when i and j belong to the same group \({G}_{{t}_{i},{\alpha }_{i}}\), the updating of \({r}_{i}^{G}\) is analogous to updating the universal reputation, but through comparing \({r}_{i}^{G}\) with \({r}_{j}^{G}\). However, when j is out-group, prejudice comes into play and i’s in-group reputation is compared with j’s universal reputation as discounted by i’s prejudice level. If i defects and j’s discounted reputation \({r}_{j}^{U}\cdot \mathrm{(1}-{\alpha }_{i})\) is less than \({r}_{i}^{G}\) then this is deemed legitimate by i’s in-group and i’s in-group reputation remains unchanged, otherwise \({r}_{i}^{G}\) is decremented. Note that in-group reputation may deviate from universal reputation as a consequence of prejudice.

The donation behavior of each agent i (i.e., the action rule) is governed by a social comparison heuristic, denoted H i = (s i , u i , d i , α i , P i , S i ). Upon being selected to play, an agent i randomly determines its potential recipient j, using the probability S i to determine whether j is selected from in-group (with probability 1 − S i that i is selected from an out-group). Variables s i , u i , d i and α i allow a donor agent i to compare its reputation against that of the potential recipient j, and to make the donation decision.

An agent i plays a donation game by comparing its reputation against that of j, and three outcomes are possible. Assuming i and j are in the same group, these are similarity \(({r}_{j}^{G}={r}_{i}^{G})\), upward self-comparison \(({r}_{j}^{G} > {r}_{i}^{G})\), or downward self-comparison \(({r}_{j}^{G} < {r}_{i}^{G})\). The reputation \({r}_{j}^{G}\) is replaced with \({r}_{j}^{U}\cdot \mathrm{(1}-{\alpha }_{i})\) in these comparisons when j is out-group to i. The binary variables from i’s social comparison heuristic govern whether or not i donates when similarity (s i ), upward comparison (u i ) or downward comparison (d i ) is observed by i in respect of j. On closure of a generation, a reproductive step conducts natural selection on the social comparison heuristics. Similar to approaches used in a spatial context (e.g.15,65), we limit the opportunity for each agent’s reproduction at an evolutionary step to be 10%. This controls potential genetic drift due to selection from within small sub-populations, and the reproductive step is repeated over 50,000 generations, unless otherwise stated. At each reproductive step, if selected to reproduce, an agent i chooses another agent’s social comparison heuristic to copy. Based on the Island model49,66, copying may be local (i.e., from within the in-group) with probability P i or from the whole population (with probability 1 − P i ). Agent i then selects a new social comparison heuristic with chance proportional to the relative fitness of the in-group members or the whole population, while further applying a random mutation to each element of the agent’s new social comparison heuristic, at the rate of 1%25. The fitness of an agent is taken as the cumulative difference between the benefits received and costs paid since the previous reproductive step. This genetic reproduction extends that applied in previous work25, and follows the general approach of asexual reproduction49.

Note that the reproductive process represents a way in which an agent i effectively learns from others, by probabilistic copying, based on the proportional fitness. P i controls the extend to which this learning is in-group, where only the strategies (i.e., social comparison heuristics) of agents in the same group \({G}_{{t}_{i},{\alpha }_{i}}\) are considered. When P i is low, agent i has a greater chance of learning from beyond its own group, across the wider population. For various experiments P i and S i may be exogenously fixed, enabling the influence of these variables to be assessed. A summary of the key parameters is presented in Table 1. The subtle dynamics underlying donation and reputation systems impede formal analysis (such as evolutionary stable strategies), but as in wide ranging studies where this is also the case15,25,26,65,67, we employ agent-based simulation. A summary of the pseudocode is also presented in Fig. 1.

Table 1 Key parameters of the model for an agent i. Full size table