This document describes the major modules inside core/, how they collaborate during a simulation, and where to look when extending behaviour.
run.pyloads and normalises configuration viacore.utils.build_merged_config().Simulation(**cfg)constructs subsystems (population, scheduler, metrics collector, optional ILM manager).- Each tick the scheduler decides which agents act; agents communicate according to the contact policy; heard tokens trigger adoption and lexicon updates.
- Metrics are collected and written to disk via
core.metrics.DataCollectorandcore.vizhelpers.
config → Simulation → Population → Agents ↔ Network → Metrics/DataCollector
core/simulation.py: Orchestrates setup and the main loop. Handles scheduled events (network rewiring, cascade injections, ILM turnover) and delegates communication to the population.core/population.py: Builds the agent roster, attaches network structure, and offers utilities for component-aware splits/merges. Also exposes hooks used by ILM to rebuild mentorship networks.core/agent.py: Implements the agent state machine—producing utterances, hearing input, adopting forms, and advancing the morphology lifecycle.core/adoption.py: Policy factories for deciding whether to adopt a heard form (bernoulli,degree,cumulative,semantic_router).core/induction.py&core/compression.py: Lexicon update steps that fill missing paradigm cells (induction) and reduce morphological complexity (compression).core/contact.py: Strategies for selecting interlocutors (broadcast,random,k_random).core/forms/morphology.py: Represents morphological paradigms, computes signatures/patterns, and serialises lexicons for analysis.core/phonology/: Rule implementations and cascade utilities that reshape forms before they are produced or adopted.core/network.py: Graph builders (scale_free,log_normal,erdos_renyi,complete) plus utilities to split/merge components while preserving IDs for downstream analysis.core/scheduler.py: Tick-level scheduling (sync,async,randomized_async) and event grouping.core/metrics.py&core/viz.py: Collect numerical metrics, produce plots, and export GIFs/images summarising evolution.core/cache.py&core/population_utils.py: Cache initial morphologies and lexicons so repeated runs with the same parameters can start quickly.core/semantics.py: Optional semantic vector space used bysemantic_routeradoption.core/ilm.py: Implements iterated learning—learner turnover, mentorship assignment, and network rebuilding between generations.core/utils.py: Configuration helpers (merging defaults, normalising aliases, seed management).
- New adoption or contact strategies: Add a factory function in the relevant module and expose it in
POLICIES. Document parameters in your experiment config. - Custom events: Extend
Simulation.perform_event(or helper modules) to react to newsimulation.eventsentries. - Additional phonology rules: Implement in
core/phonology/rule_library.pyand reference by name in configs. - Metrics: Extend
core/metrics.DataCollectoror build post-processing notebooks/scripts that consume the data underdata/<run_name>/.
Most subsystems accept dependency-injected classes or callables through the config. Inspect the dataclasses near the top of each module for supported parameters and defaults.