Skip to content

doesburg11/SocialBehavior

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SocialBehavior

A collection of agent-based models exploring human social behavior. Includes interactive UIs and grid search tools for parameter exploration.

Models

Altruism Model

  • 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 UI
    • altruism_grid_search.py: Grid search for coexistence probabilities
    • plot_coexistence_surface.py, plot_heatmaps.py: Visualization scripts
    • grid_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
  • Requirements:
    • Python 3.8+
    • numpy
    • pygame (for UI)
    • matplotlib (for plotting)
    • torch (for surface fitting)

Cooperation Model

  • 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 logic
    • cooperation_pygame_ui.py: Pygame-based interactive UI
    • Cooperation.nlogox: Original NetLogo model
  • Usage:
    • Run CLI demo:
       python cooperation/cooperation_model.py
    • Run Pygame UI:
       python cooperation/cooperation_pygame_ui.py
  • Requirements:
    • Python 3.8+
    • numpy
    • pygame
    • matplotlib

Installation

Install dependencies:

pip install numpy pygame matplotlib torch

For Pygame visualization, you may need:

conda install -y -c conda-forge gcc=14.2.0

References

  • Original NetLogo models from Uri Wilensky and the EACH unit (Evolution of Altruistic and Cooperative Habits)
  • See altruism/README.md and cooperation/Cooperation.nlogox for more details

About

A collection of python implementations exploring (human) social behavior.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages