DOI: 10.5061/dryad.44j0zpcr5
title: Evolutionary advantage of guilt: Co-evolution of social and non-social guilt in structured populations

description: Building ethical machines may involve bestowing upon them the emotional
 capacity to self-evaluate and repent on their actions. While apologies
 represent potential strategic interactions, the explicit evolution of
 guilt as a behavioural trait remains poorly understood. Our study delves
 into the co-evolution of two forms of emotional guilt: social guilt
 entails a cost, requiring agents to exert efforts to understand
 others' internal states and behaviours; and non-social guilt, which
 only involves awareness of one's own state, incurs no social cost.
 Resorting to methods from evolutionary game theory, we study analytically,
 and through extensive numerical and agent-based simulations, whether and
 how guilt can evolve and deploy, depending on the underlying structure of
 the systems of agents. Our findings reveal that in lattice and scale-free
 networks, strategies favouring emotional guilt dominate a broader range of
 guilt and social costs compared to non-structured well-mixed populations,
 so leading to higher levels of cooperation. In structured populations,
 both social and non-social guilt can thrive through clustering with
 emotionally inclined strategies, thereby providing protection against
 exploiters, particularly for less costly non-social strategies. These
 insights shed light on the complex interplay of guilt and cooperation,
 enhancing our understanding of ethical artificial intelligence.
description: Computational simulation of evolutionary game theory interactions
 on networks, ran using Agents.jl in Julia. Equilibria analysis and
 replicator dynamics solving done using a mix of Julia and Python.
 Processed using various Julia data and analysis facilities (DataFrames.jl,
 PlotlyJS.jl, Makie.jl).
description: # Evolutionary advantage of guilt: Co-evolution of social and non-social
 guilt in structured populations
 [https://doi.org/10.5061/dryad.44j0zpcr5](https://doi.org/10.5061/dryad.44j0zpcr5) ## Description of the data and file structure Data generated for the "The Evolutionary Advantage of Guilt: Insights from Networked Multi-Agent Systems" paper authored by Theodor Cimpeanu, Luis Moniz Pereira and The Anh Han. Abstract: Building ethical machines may involve bestowing upon them the emotional capacity to self-evaluate and repent on their actions. While apologies represent potential strategic interactions, the explicit evolution of guilt as a behavioural trait remains poorly understood. Our study delves into the co-evolution of two forms of emotional guilt: social guilt entails a cost, requiring agents to exert efforts to understand others' internal states and behaviours; and non-social guilt, which only involves awareness of one's own state, incurs no social cost. Resorting to methods from evolutionary game theory, we study analytically, and through extensive numerical and agent-based simulations, whether and how guilt can evolve and deploy, depending on the underlying structure of the systems of agents. Our findings reveal that in lattice and scale-free networks, strategies favouring emotional guilt dominate a broader range of guilt and social costs compared to non-structured well-mixed populations, so leading to higher levels of cooperation. In structured populations, both social and non-social guilt can thrive through clustering with emotionally inclined strategies, thereby providing protection against exploiters, particularly for less costly non-social strategies. These insights shed light on the complex interplay of guilt and cooperation, enhancing our understanding of ethical artificial intelligence. ### Files and variables #### File: guilt.zip **Description:** Archive contains several large files that describe ensemble runs for different networks: Figure 3 was generated using file guilt_wm_sixstrats (well-mixed networks). Figure 4 was generated using files guilt_lattice_sixstrats_moreres (for b/c ratio 2 in lattice networks) and guilt_lattice_sixstrats_fignew (for b/c ratio 4 in lattice networks). Figure 6 was generated using files guilt_sf_sixstrats_upto3 (for b/c ratio 2 in sf networks) and guilt_sf_sixstrats_fignew (for b/c ratio 4 in sf networks). Files guilt_sf_firstmodel_fig2 (social guilt only, sf networks) and guilt_sf_secondmodel_fig2 (non-social guilt only, sf networks) were used to generate figure S3 in the appendix. ### Variables in code and data files: * *freq_c:* mean frequency of players with strategy C * *freq_d:* mean frequency of players with strategy D * *freq_dgd1:* mean frequency of players with strategy DGDN * *freq_dgc1:* mean frequency of players with strategy DGCN * *freq_dgd2:* mean frequency of players with strategy DGDS * *freq_dgc2:* mean frequency of players with strategy DGCS * *step:* current step (generation) in the simulation * *gammo:* cost of being social (same as \gamma_s in main text) * *gamma:* internal cost of guilt (same as \gamma in main text) * *b:* benefit of cooperation * *seed:* index of replicate (actual seed of replicate is generated using current system time) * *net_seed:* seed of random number generator used for generating the scale-free network * *clustering_type:* FALSE for BA scale-free networks and TRUE for DMS scale-free networks ### Variables only present in code: * *c:* cost of cooperation * *T:* temptation  * *R:* reward * *P:* punishment * *S:* sucker's payoff * *theta:* number of rounds in iterared prisoner's dilemma (same as \theta in main text) * *numagents:* size of population (same as N in main text) * *beta:* intensity of selection (\beta in main text) * *mutation_rate:* rate of mutation (\mu in main text) ## Code/software Julia files can be opened using most text editors, but to run the code a working Julia implementation is required. The code was generated using Julia versions 1.7.0/1.8.0 and associated Agents.jl (v5.0.0). Current Agents.jl iterations probably require some syntax modifications to run the code.  Similarly to the data, the code files are named according to the type of population structure (*wm for well-mixed,* *lattice for lattice, and* *sf for scale-free). The guilt*_plots.jl file holds all the code for plotting the figures. The markov.ipnyb and markov.jl files have the code for the numerical solver (using replicator dynamics or markov chains) and for finding equilibria points using this. The julia solver is virtually identical to the python version, and we used it for the faster computation in julia compared to python when doing a large sweep searching for stable equilibria.  Files were generated by changing the parameters in the simulations, then processed and analysed using the plotting methods available through Julia's PlotlyJS and Makie packages. Python code can be ran using Jupyter notebooks.