算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
mesa【设计与创意】Use Mesa for agent-based simulation models, spatial ABM environments, experiment data collection, scenarios, and Solara visualization workflows.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this repo skill when a task involves Mesa, the Python agent-based modeling framework: building ABM models, managing agents, adding spaces, collecting outputs, running scenarios, or creating browser/notebook visualizations.
Mesa requires Python 3.12 or newer in this snapshot.
python -m pip install -U mesa
# For Mesa 4 pre-releases when a task depends on APIs from this skill:
python -m pip install -U --pre mesa
# Recommended optional stacks:
python -m pip install -U "mesa[network]" # Network spaces
python -m pip install -U "mesa[viz]" # Solara/matplotlib/altair visualization
python -m pip install -U "mesa[rec]" # network + viz recommended extras
Minimal import check:
import mesa
from mesa import Agent, DataCollector, Model
from mesa.discrete_space import OrthogonalMooreGrid
Run scripts/check_mesa_install.py for a safe JSON probe of the installed package and optional extras.
| Task intent | Read |
|---|---|
Define Model and Agent classes, create agents, activate AgentSets, seed RNGs, schedule events, run time, remove agents | model-core |
| Choose grids/cells/network/Voronoi/continuous spaces, move cell agents, use property layers, debug capacity or coordinates | spaces |
| Collect model/agent/table outputs, create DataFrames, run scenarios, use experimental recorders/actions/states/signals | analysis-experiments |
Build or debug SolaraViz, SpaceRenderer, component builders, portrayal styles, plots, user parameters, visualization extras | visualization |
Agent.__init__(model) automatically registers the agent and assigns unique_id. Do not reassign or manually mutate model.agents.Model(rng=...) creates both model.rng and model.random; pass rng for reproducibility unless a Scenario instance already owns the RNG.Model.step() is scheduled by default every 1.0 time units; use run_for() or run_until() to process the event queue.model.agents.do(...), shuffle_do(...), map(...), select(...), groupby(...), and agg(...) over custom scheduler objects.mesa.discrete_space or mesa.experimental.continuous_space, not legacy mesa.space APIs.DataCollector supports model, agent, agent-type, and table outputs; avoid lambdas when the model must be pickle-safe.SolaraViz re-creates models from model_params; model constructors must accept keyword arguments matching those parameter keys.mesa install.Network default layouts: install mesa[network] or pass your own graph/layout stack.mesa[viz] or mesa[rec].mesa[examples] includes recommended extras and pytest.