Skip to main content

Slime Flow Python SDK

Python client for the Slime Flow GPU swarm simulation server.

Install

pip install -e python-sdk/        # from repo root
# or with async + numpy support:
pip install -e "python-sdk/[all]"

Quick Start

from slimeflow import SlimeFlow

sf = SlimeFlow("localhost", 8080)

# Check server status
status = sf.status()
print(f"GPU: {status.gpu}")

# Get a frame
frame = sf.frame()
print(f"Step {frame.step}, {frame.rogue_count} rogues")
print(f"Density: {frame.density():.3f}")

# Inject chaos
sf.spawn_rogues()
sf.inject_fault(0.5, 0.3)

# Stream frames
for frame in sf.stream(max_frames=100):
    if frame.rogue_count > 10:
        sf.clear_fault()

API

Method Description
sf.status() → Status Server info, GPU, step count
sf.frame() → Frame Advance 1 step, return frame
sf.reset() Reset simulation
sf.spawn_rogues() Inject rogue agents
sf.inject_fault(x, y) Inject fault zone (0–1 coords)
sf.clear_fault() Clear fault zone
sf.ping() → bool Check server reachable
sf.stream(interval, max_frames) → Iterator[Frame] Blocking frame stream
await sf.async_stream(...) → AsyncIterator[Frame] Async frame stream

Frame Object

frame.step          # int — simulation step
frame.grid_w        # int — grid width (64)
frame.grid_h        # int — grid height (64)
frame.pheromone     # list[float] — pheromone grid (0–1)
frame.rogue_pheromone  # list[float] — rogue pheromone grid
frame.agents        # list[Agent] — all 512 agents
frame.rogue_count   # int
frame.quarantine_count  # int
frame.fault_active  # bool

# Computed
frame.density()     # float — average pheromone
frame.peak()        # float — max pheromone
frame.integrity()   # float — swarm health (0–100%)
frame.mean_anomaly()  # float — avg rogue anomaly
frame.alive_count() # int
frame.type_counts() # dict — {1: n_scouts, 2: n_harvesters, ...}
frame.grid_2d()     # list[list[float]] — 2D pheromone
frame.grid_np()     # np.array (requires numpy)
frame.agents_np()   # dict of np arrays (requires numpy)

Agent Object

ag.x, ag.y          # float — normalized position (0–1)
ag.type             # int — 1=Scout, 2=Harvester, 3=Guardian, 4=Emergent, 5=Rogue
ag.anomaly          # float — anomaly score (0–1)
ag.quarantine       # int — 0=active, 1=quarantined, 2=fault-killed
ag.type_name        # str — "Scout", "Harvester", etc.
ag.is_rogue         # bool
ag.is_quarantined   # bool
ag.is_dead          # bool
ag.is_active        # bool

Examples

# Check server + get frame
python examples/basic.py check
python examples/basic.py frame
python examples/basic.py chaos

# Async streaming
python examples/async_example.py monitor
python examples/async_example.py chaos

Requirements

  • Python 3.9+
  • Optional: numpy for array operations
  • Optional: httpx for async client
  • Running Slime Flow server (julia server.jl)

Metadata

Release files for slimeflow 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slimeflow 0.2.1
File Size Uploaded
slimeflow-0.2.1.tar.gz 19.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slimeflow 0.2.1
File Interpreter ABI Platform
slimeflow-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.1 kB

Release files / slimeflow-0.2.1.tar.gz

Download URL slimeflow-0.2.1.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
da8b5af561c77681a25d62264823ce6f8853599b68790e54044239aa0f743d1c
BLAKE2b-256 checksum
How to use checksums
6bf916388af5fd7764a1eddec3fa500672ef8bfc716ff53cc4cfcc29fafccf5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / slimeflow-0.2.1-py3-none-any.whl

Download URL slimeflow-0.2.1-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e3c2b20ec1a239c36393e4931b10894b11303005dcd06fab2854c43ef3932b9
BLAKE2b-256 checksum
How to use checksums
f310323f74c3d52ee5d3ecf13261ef4f72ce31e57b63e871c13f68a82f9465d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release 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