Skip to main content

Logic Lab

Python translations of creative coding examples using py5. Each simulation is organized by domain, demonstrating core computational creativity concepts: physics, steering behaviors, genetic algorithms, neural networks, fractals, cellular automata, tiling patterns, and mathematical systems.

MCP Server

Logic Lab is available as an MCP server for AI agents. Agents can search the Logic Lab manifest, find algorithms by visual intent or category, read short summaries, and fetch bounded source snippets for selected examples.

Glama MCP Server

Option 1: Quick Start

If you just want to use the MCP server directly via Glama or your AI agent without cloning the repository, you can run it remotely using uvx.

Add the following to your AI tool's MCP

configuration:

{
  "mcpServers": {
    "logic-lab": {
      "command": "uvx",
      "args": [
        "--from",
        "logic-lab",
        "logic-lab-mcp"
      ]
    }
  }
}

Option 2: Manual Installation (For local development)

Requires uv. Clone this repository locally if you want to modify the algorithms or run the server from your local source.

git clone https://github.com/asamiile/logic-lab.git
cd logic-lab
uv sync

Registration (Local)

After manual installation, register the local server with your AI tool using the logic-lab-mcp command:

Claude Code:

claude mcp add logic-lab -- logic-lab-mcp

Codex:

codex mcp add logic-lab -- logic-lab-mcp

GitHub Copilot in VS Code (.vscode/mcp.json or user MCP settings):

{
  "servers": {
    "logic-lab": {
      "type": "stdio",
      "command": "logic-lab-mcp"
    }
  }
}

Cursor (.cursor/mcp.json or ~/.cursor/mcp.json):

{
  "mcpServers": {
    "logic-lab": {
      "type": "stdio",
      "command": "logic-lab-mcp"
    }
  }
}

Available Tools

303 algorithms across 11 domains are accessible via 6 MCP tools:

Tool Description
search_algorithms(query, category, limit) Free-text search across titles, concepts, and visual descriptions. Start here.
search_by_mood(mood, style, limit) Find algorithms by aesthetic mood: ethereal, chaotic, geometric, organic, cosmic, minimal, and 6 more.
recommend_combinations(intent, count) Returns layered multi-algorithm recipes for a given artistic intent.
get_algorithm_summary(path) Returns manifest metadata and README excerpt for a path. Check relevance before fetching source.
get_algorithm(path, max_chars) Returns source code for a specific algorithm file. Read-only, size-limited.
get_manifest() Returns the full manifest JSON. Use when you need to enumerate all entries or categories.

Recommended workflow: search_algorithmsget_algorithm_summaryget_algorithm

See src/logic_lab/mcp/README.md for full parameter reference, security notes, and resource endpoints.

Agent Conversation Example

User: I want to create flowing smoke with invisible force fields.

Agent: Running search_algorithms("flowing smoke invisible force fields")...

  • steering_behaviors/flow_field.py — particles following a fluid vector field
  • physics/fluid_simulation.py — grid-based fluid dynamics

Checking details with get_algorithm_summary("steering_behaviors/flow_field.py")... complexity: medium, concepts: [flow field, Perlin noise, autonomous agents]

Fetching source with get_algorithm("steering_behaviors/flow_field.py") to use as reference for implementation.

Algorithm Domains

  • mathematical/ - Generative geometry, color harmony, noise functions, fractals
  • physics/ - Particle systems, forces, spring physics, fluid dynamics, collision
  • steering_behaviors/ - Autonomous agents, flocking, pathfinding, flow fields
  • genetic_algorithms/ - Evolution, selection, crossover, mutation
  • neuro_evolution/ - Neural networks evolved via genetic algorithms
  • fractals/ - Recursive structures, space-filling curves, Mandelbrot sets
  • cellular_automata/ - Rule-based systems, Game of Life, emergence
  • tiling_patterns/ - Symmetry, tessellations, ornamental patterns
  • research/ - Experimental systems combining multiple domains
  • simulation/ - Prototype implementations and archived experiments
  • shader/ - GLSL fragment shaders for TouchDesigner and UE5

Example: Autonomous Artwork Generation

py5-media-art — a project that uses the Logic Lab MCP server with Claude Code to autonomously generate py5 sketches. Claude searches Logic Lab for relevant algorithms, adapts them into new compositions, and optionally writes accompanying articles.

Gallery

Examples of generative art created with Logic Lab algorithms:

Watch on YouTube

Development

To contribute new algorithms or fixes, see CONTRIBUTING.md for detailed guidelines on:

  • Development setup with uv
  • Algorithm addition workflow
  • py5 code patterns and templates
  • Testing requirements
  • Conventional Commits specification
  • Automated release process

Setup

Install dependencies:

uv sync

Running Tests

# Install dev dependencies
uv sync --group dev

# Run all tests
uv run pytest tests/

# Run with coverage
uv run pytest tests/ --cov=src/logic_lab

Code Quality

# Lint with ruff
uv run ruff check src/ tests/

# Format with black
uv run black src/ tests/

# Lint and fix
uv run ruff check --fix src/ tests/

Repository Structure

logic-lab/
├── src/logic_lab/                 # Package root
│   ├── __init__.py
│   ├── mcp/                       # MCP server for AI agent access
│   ├── physics/                   # Motion, forces, particles, simulations
│   ├── steering_behaviors/        # Autonomous agents, flow fields, flocking
│   ├── genetic_algorithms/        # Selection, mutation, evolutionary search
│   ├── neuro_evolution/           # Neural networks evolved via genetics
│   ├── fractals/                  # Recursion, trees, Koch curves, L-systems
│   ├── cellular_automata/         # Rule-based grids, lattice systems
│   ├── mathematical/              # Noise, curves, geometry, harmony
│   ├── tiling_patterns/           # Symmetry, tessellation, ornaments
│   ├── research/                  # Experimental and hybrid systems
│   ├── simulation/                # Prototypes and reference implementations
│   ├── shared/                    # Reusable utilities and helpers
│   └── shader/                    # GLSL shader experiments
├── tests/                         # Pytest test suite
├── CONTRIBUTING.md                # Contributor guidelines and conventions
├── CHANGELOG.md                   # Version history and release notes
├── pyproject.toml                 # Package configuration and dependencies
└── .github/workflows/
    ├── test.yml                   # CI: lint and test automation
    └── release.yml                # CD: automated releases with release-please

Reference

License

License: MIT

Author

Asami.K

If you find this helpful, consider supporting the work:

BuyMeACoffee

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logic_lab-0.4.0.tar.gz (507.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logic_lab-0.4.0-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file logic_lab-0.4.0.tar.gz.

File metadata

  • Download URL: logic_lab-0.4.0.tar.gz
  • Upload date:
  • Size: 507.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for logic_lab-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a3137657e4a407c052bfa2c6f22b1903483cf0f4883876d9cb380fb45917f4d6
MD5 e1723fe1a6619235c1abee2113bffa89
BLAKE2b-256 1d6a2ddd2c67a2990edcdd7f662b5e1505177a1690a97a7517911084e70b860f

See more details on using hashes here.

Provenance

The following attestation bundles were made for logic_lab-0.4.0.tar.gz:

Publisher: release.yml on asamiile/logic-lab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logic_lab-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: logic_lab-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for logic_lab-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32e8b016e9c9cc3cf18e271d8d7eda7ecb291c63a5524b0987aa7513454873e6
MD5 5b4448f6ade7534aca6ef8d73d8aaff5
BLAKE2b-256 22f9073f6ec98b9b44c42d1ddc142b5a9aec3f7d1688ad118be6fd4c4688fb66

See more details on using hashes here.

Provenance

The following attestation bundles were made for logic_lab-0.4.0-py3-none-any.whl:

Publisher: release.yml on asamiile/logic-lab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page