Skip to main content

Kin Selection

Status

Python-backed. This page describes the moran_models/nowak_mechanisms/kin_selection/ package in the sibling EvolvedCooperation repository. It is not yet a browser replay case study.

Kin selection is the first of Nowak's five mechanisms for the evolution of cooperation. Cooperation spreads when the benefit delivered to a recipient, weighted by genetic relatedness, exceeds the private cost paid by the actor — Hamilton's rule: rB>CrB > C.

How It Is Implemented Here

Relatedness is operationalised through lineage labels. Every site carries an inherited lineage identifier. The positive routing kernel assigns higher weight to same-lineage neighbors than to other-lineage neighbors:

Kji+{wsameif lineagej=lineageiwotherotherwiseK^+_{j \to i} \propto \begin{cases} w_{\text{same}} & \text{if lineage}_j = \text{lineage}_i \\ w_{\text{other}} & \text{otherwise} \end{cases}

with row normalization applied afterward. Because offspring inherit the parent's lineage label, cooperator clusters accumulate same-lineage neighbors over time, which progressively recirculates more of the cooperative benefit back toward cooperators — the positive feedback that makes cooperation viable.

One Step

One full synchronous kin-selection update runs as follows. All sites update simultaneously.

Kin Selection Simulation Step
One synchronous grid update from step t to step t + 1 under kin-selection routing.
1

Start from the current grid state

Each site stores one cooperation trait hh and one inherited lineage label.

2

Compute cooperative output and private cost

Bi+=Bplushi,Ci=CscalehiB_i^+ = B_{\text{plus}} \cdot h_i, \qquad C_i = C_{\text{scale}} \cdot h_i

3

Build the kin-weighted routing kernel

Assign raw weight wsamew_{\text{same}} to same-lineage neighbors and wotherw_{\text{other}} to other-lineage neighbors, then row-normalize:

wij={wsameif lineagei=lineagejwotherotherwiseKij+=wijkwikw_{ij} = \begin{cases} w_{\text{same}} & \text{if } \text{lineage}_i = \text{lineage}_j \\ w_{\text{other}} & \text{otherwise} \end{cases} \qquad K_{ij}^+ = \frac{w_{ij}}{\sum_k w_{ik}}

4

Accumulate lineage-weighted receipts

Each site sums the kin-weighted share of cooperative benefit received from its neighbors:

Ri+=jKji+Bj+R_i^+ = \sum_j K_{ji}^+ \cdot B_j^+

5

Compute site fitness

Wi=w0+Ri+CiW_i = w_0 + R_i^+ - C_i

Baseline fitness w0w_0 dampens selection intensity.

6

Sample a local parent by softmax over fitness, copy trait and lineage

Parent selection is restricted to the site's local neighborhood. The offspring inherits trait hh (with small Gaussian mutation) and lineage label — same-lineage clusters grow when cooperators reproduce locally.

Display 1: One synchronous kin-selection update from step t to step t + 1.

Production

Each site produces cooperative output and pays a private cost proportional to its trait:

Bi+=BplushiB_i^+ = B_{\text{plus}} \cdot h_i

Ci=CscalehiC_i = C_{\text{scale}} \cdot h_i

Kernel construction

For each producer ii, a raw routing weight wijw_{ij} is assigned to each neighbor jj based on lineage match, then row-normalized so weights sum to 1:

wij={wsameif lineagei=lineagejwotherotherwisew_{ij} = \begin{cases} w_{\text{same}} & \text{if } \text{lineage}_i = \text{lineage}_j \\ w_{\text{other}} & \text{otherwise} \end{cases}

Kij+=wijkwikK_{ij}^+ = \frac{w_{ij}}{\sum_k w_{ik}}

Routing

Each site receives the lineage-weighted share of every neighbor's production:

Ri+=jKji+Bj+R_i^+ = \sum_j K_{ji}^+ \cdot B_j^+

Fitness score

Wi=w0+Ri+CiW_i = w_0 + R_i^+ - C_i

Local replacement

Each site samples a parent from its local neighborhood via softmax over WW. The offspring inherits the parent's trait hh (with small Gaussian mutation) and lineage label. Because the lineage label is inherited, same-lineage clusters grow when local cooperators outcompete their neighbors — the feedback that sustains cooperation.

Variable definitions:

  • hih_i is site ii's cooperation trait in [0, 1]
  • Bi+B_i^+ is the cooperative benefit produced by site ii
  • CiC_i is the private cost paid by site ii
  • Kij+K_{ij}^+ is the normalized routing weight from producer ii to recipient jj
  • Ri+R_i^+ is the total routed benefit received by site ii
  • WiW_i is the fitness score used for local replacement
  • w0w_0 is the fixed baseline fitness shared by all sites, which dampens selection intensity

Key Parameters

ParameterDefaultRole
kin_weight_same_lineage0.8Routing weight toward same-lineage neighbors
kin_weight_other_lineage0.2Routing weight toward other-lineage neighbors
B_plus_scale1.0Scales cooperative benefit produced per unit trait
C_scale0.2Private cost per unit trait

Hamilton's rule maps onto these parameters as rwsame/(wsame+wother)r \approx w_{\text{same}} / (w_{\text{same}} + w_{\text{other}}), B=B = B_plus_scale, C=C = C_scale.

Python Module Layout

moran_models/nowak_mechanisms/kin_selection/
__init__.py
kin_selection_model.py
kin_selection_pygame_ui.py
config/
kin_selection_config.py
utils/
sweep_kin_selection_phase.py

Usage

./.conda/bin/python -m moran_models.nowak_mechanisms.kin_selection.kin_selection_model

Live viewer:

./.conda/bin/python -m moran_models.nowak_mechanisms.kin_selection.kin_selection_pygame_ui

References