A particle simulation written in C. Particle Life explores the concept of emergence, where complex structures arise from simple rules. Inspired by Tom Mohr's video on Particle Life simulations.
(config file for this demo: cool_configs/interesting_dynamics.txt)
./build/plife build/simulation.txtNote: Provided executable is for ARM64. For other architectures, recompile src/main.c.
Modify simulation.txt to configure simulation properties. Ensure that if you specify n quantities, the attraction matrix is n x n. We recommend a viscosity of 0.4 and a repulsion strength of 4.0 for best results.
Epochs: Number of simulation frames to renderQuantities: Number of each particle type in simulationAttraction: Attraction matrix, in same order as quantities are definedViscosity: Slows particles down as they move to prevent chaosRadius: How close particles need to be to interactRepulsionStrength: How much particles push back on eachother when getting too close (to minimize particle overlap)
Example simulation.txt:
#Epochs
1000
#Quantities
50 50
#Attraction
0.5 -0.2
-0.3 0.8
#Viscosity
0.4
#Radius
50
#RepulsionStrength
4.0The runner.py script automates the creation of simulation.txt with customizable attributes and runs the PLife simulation. Currently epochs, viscocity, radius, and repulsion strength cannot be modified with flags directly. If you wish to modify these, do so in the runner.py script directly. runner.py only supports creation of uniform particle quantities.
Note that the plife executable is still required to use the runner.
python3 runner.py -s SIZE -n NUMBER-s SIZE: Number of particle types (required).-n NUMBER: Number of particles per type (required).
Example:
python3 runner.py -s 5 -n 200-a,--assortativity:highorlow.-d,--degree: Degree distribution (integer between 1 and size of matrix-s).-c,--clustering: Clustering coefficient (0 to 1).-k,--skew-symmetry:high,medium, orlow.-r,--reciprocity: Reciprocity level (0 to 1).-p,--sparsity: Proportion of possible edges (0 to 1).
python3 runner.py -s 5 -n 200 -a highpython3 runner.py -s 5 -n 200 -p 0.2python3 runner.py -s 5 -n 200 -k high -r 0.7You can combine any number of attributes. However, some attributes will contradict each other, so note the following conditions.
- Sparsity and Degree Distribution: If both are specified, degree distribution takes precedence.
- Reciprocity and Skew Symmetry: Reciprocity is applied after skew symmetry and can override it.
- Modify
build/simulation.txtto manually adjust particles, the attraction matrix, or epochs. - The
simulation.txtfile can be renamed; specify the correct filename when running the simulation. However,runner.pyusesbuild/simulation.txt.
