egtplot: A Python Package for Three-Strategy Evolutionary Games

Drew Fk Williamson, Md, Inom Mirzaev, Drew F. K. Williamson, Jacob G. ScottJ. Open Source Softw 2018 · DOI · DBLP

Introduction

Evolutionary Game Theory (EGT) provides a robust mathematical framework for modeling the spread of strategies or biological traits within a population based on their relative fitness. In fields ranging from oncology to economics, understanding the interaction between three competing strategies is critical. However, visualizing these dynamics is challenging because the proportions of the three strategies must always sum to unity, necessitating a representation within a two-dimensional ternary simplex.

The egtplot package is an open-source Python tool designed to bridge this gap. It enables researchers to visualize the complex dynamics of three-strategy games through intuitive plots and animations, facilitating the analysis of population trajectories and equilibria based on interactive payoffs.

Core Functionality and the Replicator Equation

At the heart of egtplot is the Replicator Equation, which models how strategy frequencies evolve over time. The package is specifically optimized for games defined by a payoff matrix. Key technical features include:

  • Simplex Plotting: Mapping the three-dimensional state space onto a 2D triangle.
  • Vector Fields: Visualizing the "flow" of the population toward or away from specific strategies.
  • Trajectory Tracking: Calculating and displaying the paths taken by various initial population compositions.
  • Speed Mapping: Using color gradients to show the velocity of evolution at different points in the state space.

Visualizing the Speed of Evolution

A standout feature of the package is its ability to map the "speed" of evolution across the simplex. By applying a color gradient to the background, egtplot highlights regions where population change is rapid versus areas where the composition remains relatively stagnant.

Ternary simplex plot showing the vector field and evolutionary speed for a three-strategy game involving Stroma (S), Dependent (D), and Independent (I) cells.

This visualization is particularly useful for identifying "slow" regions that might correspond to long-term transient states in biological systems, such as the interaction between healthy stroma (S), microenvironmentally dependent (D), and independent (I) cancer cells (Basanta et al., 2012).

Parameter Sweeps and Stability Analysis

In many biological and social contexts, the payoffs of strategies are not static but depend on environmental parameters. egtplot automates the generation of parameter sweeps, allowing users to see how changing a single variable—such as the benefit of cooperation or the cost of resource extraction—alters the entire system's stability.

A parameter sweep demonstrating how variations in biological parameters alpha and beta shift the system's stability and evolutionary flow across four distinct scenarios.

As shown in the parameter sweep above, the tool makes it immediately apparent where stable equilibria (sinks) and unstable equilibria (sources) exist. For instance, in models of prostate cancer, the software can reveal lines of stable equilibria between different cell types, providing insights into how therapeutic interventions might shift the evolutionary landscape.

Conclusion and Limitations

By providing a high-level interface for payoff matrices, egtplot lowers the barrier for non-mathematicians to apply game theory to experimental data without needing to manually solve systems of differential equations. While currently limited to three-strategy games and matrix-based interactions, it remains a powerful tool for visualizing the fundamental dynamics of competition and cooperation in evolving populations.

Summary updated

BibTeX
@article{md2018egtplot,
  author = {Drew FK Williamson, MD and Inom Mirzaev and Drew F. K. Williamson and Jacob G. Scott},
  title = {{egtplot: A Python Package for Three-Strategy Evolutionary Games}},
  journal = {J. Open Source Softw},
  year = {2018},
  doi = {10.21105/joss.00735},
}
Figure