A collection of agent-based models exploring human social behavior. Includes interactive UIs and grid search tools for parameter exploration.
- Description: Patch-based grid simulation of altruism vs selfishness, ported from NetLogo to Python/NumPy.
- Features:
- Each cell can be empty (black), selfish (green), or altruist (pink)
- Simulates benefit/cost of altruism, fitness, and generational updates
- Fully vectorized NumPy implementation for fast simulation
- Pygame UI for interactive exploration
- Matplotlib plots for population dynamics
- Grid search for parameter sweeps
- Files:
altruism_model.py
: Core simulation logic (importable class, CLI demo, and plotting)altruism_pygame_ui.py
: Pygame-based interactive UIaltruism_grid_search.py
: Grid search for coexistence probabilitiesplot_coexistence_surface.py
,plot_heatmaps.py
: Visualization scriptsgrid_search_results.csv
: Results from grid search
- Usage:
- Run CLI demo:
python altruism/altruism_model.py --steps 200 --width 101 --height 101 --seed 42
- Run Pygame UI:
python altruism/altruism_pygame_ui.py
- Run grid search:
python altruism/altruism_grid_search.py
- Run CLI demo:
- Requirements:
- Python 3.8+
- numpy
- pygame (for UI)
- matplotlib (for plotting)
- torch (for surface fitting)
- Description: Evolutionary biology model of greedy vs cooperative agents (cows) competing for grass, ported from NetLogo.
- Features:
- Agents move, eat, reproduce, and die based on energy and grass availability
- Cooperative cows avoid eating low grass, greedy cows eat regardless
- Grass regrows at different rates depending on height
- Pygame UI for visualization
- Files:
cooperation_model.py
: Core simulation logiccooperation_pygame_ui.py
: Pygame-based interactive UICooperation.nlogox
: Original NetLogo model
- Usage:
- Run CLI demo:
python cooperation/cooperation_model.py
- Run Pygame UI:
python cooperation/cooperation_pygame_ui.py
- Run CLI demo:
- Requirements:
- Python 3.8+
- numpy
- pygame
- matplotlib
Install dependencies:
pip install numpy pygame matplotlib torch
For Pygame visualization, you may need:
conda install -y -c conda-forge gcc=14.2.0
- Original NetLogo models from Uri Wilensky and the EACH unit (Evolution of Altruistic and Cooperative Habits)
- See
altruism/README.md
andcooperation/Cooperation.nlogox
for more details