Skip to main content

Deterministic Weiss Schwarz simulator with a Rust core and Python bindings.

Project description

Weiss Schwarz Simulator

CI Wheels Benchmarks Security PyPI Rustdoc Docs Hub

Deterministic Weiss Schwarz simulation for RL and engine research.

What you get

  • Rust engine (weiss_core) with deterministic advance-until-decision stepping
  • PyO3 bindings (weiss_py) and Python API (python/weiss_sim) for batched training/eval loops
  • Stable observation/action contracts (OBS_LEN=378, ACTION_SPACE_SIZE=527, SPEC_HASH=8590000130)
  • Replay and fingerprint surfaces for drift detection and reproducibility

5-minute start

Option A: install from PyPI

python -m pip install -U weiss-sim numpy

Option B: local build from source

python -m pip install -U maturin numpy
python -m maturin develop --release --manifest-path weiss_py/Cargo.toml

Run the commands in the Python environment where you want weiss_sim installed. If you are using a virtualenv, activate it first.

Option C: contributor setup (dev extras + local extension)

rustup component add rustfmt clippy
python -m venv .venv
# activate the virtualenv before the next commands
# PowerShell: .\.venv\Scripts\Activate.ps1
# Bash / zsh: source .venv/bin/activate
python -m pip install -U pip
python -m pip install -e ".[dev]"
python -m maturin develop --release --manifest-path weiss_py/Cargo.toml

This installs .[dev] extras (ruff, pytest, maturin, pip-audit) and builds the local extension in-place.

Virtualenv activation examples:

  • PowerShell: .\.venv\Scripts\Activate.ps1
  • Bash / zsh: source .venv/bin/activate

If you prefer the helper script, scripts/setup_dev_env.sh runs the same install flow in Bash-compatible shells.

Minimal high-level loop

import numpy as np
import weiss_sim

with weiss_sim.fast(num_envs=32, seed=0) as sim:
    reset = sim.reset()
    actions = reset.legal.sample_uniform(seed=123)
    step = sim.step(actions)

Minimal low-level loop

import numpy as np
import weiss_sim

legal_deck = (list(range(1, 14)) * 4)[:50]

pool = weiss_sim.EnvPool.new_rl_train(
    32,
    deck_lists=[legal_deck, legal_deck],
    deck_ids=[1, 2],
    seed=0,
)
buf = weiss_sim.EnvPoolBuffers(pool)
out = buf.reset()
actions = np.full(pool.envs_len, weiss_sim.PASS_ACTION_ID, dtype=np.uint32)
out = buf.step(actions)

Deck authoring flow (Python)

import weiss_sim

builder = weiss_sim.cards.builder(initial="starter_v1")
builder.set_count("CARD-1", 4)
report = builder.validate(rules_profile="approx", card_pool="all")
if report.ok:
    deck_ids = builder.build(rules_profile="approx", card_pool="all")

Architecture at a glance

flowchart LR
  A["Python API\npython/weiss_sim"] --> B["PyO3 bindings\nweiss_py"]
  B --> C["Engine core\nweiss_core"]
  C --> D["Deterministic outputs\nobs/masks-or-ids/reward/status"]
  C --> E["Replay + fingerprint\nrepro & drift debugging"]

Documentation map

Start in docs/README.md.

Recommended paths:

Repository layout

  • weiss_core/: Rust engine and deterministic rule runtime
  • weiss_py/: PyO3 extension layer
  • python/weiss_sim/: high-level and low-level Python interfaces
  • python/tests/: Python API/contract tests
  • scripts/: CI parity, coverage, perf, and docs checks
  • docs/: user + contributor documentation hub

Local quality checks

Full local CI parity:

bash scripts/run_local_ci_parity.sh

On Windows, run the underlying commands directly from PowerShell:

cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test --workspace --all-features
python -m ruff format --check python scraper scripts
python -m ruff check python scraper scripts
python scripts/check_docs_links.py
python scripts/check_docs_constants.py
python scripts/gen_docs_snippets.py --check
python -m pytest -q python/tests

Skip benchmark gate during iteration:

SKIP_BENCHMARKS=1 bash scripts/run_local_ci_parity.sh

Docs-only checks:

python scripts/check_docs_links.py
python scripts/check_docs_constants.py
python scripts/gen_docs_snippets.py --check

Benchmark snapshot (main)

Last updated: 2026-04-28 20:50 UTC

Benchmark Time
rust/advance_until_decision 46153 ns/iter
rust/step_batch_64 15586 ns/iter
rust/reset_batch_256 875519 ns/iter
rust/step_batch_fast_256_priority_off 91069 ns/iter
rust/step_batch_fast_256_priority_on 89474 ns/iter
rust/legal_actions 11 ns/iter
rust/legal_actions_forced 12 ns/iter
rust/on_reverse_decision_frequency_on 1381 ns/iter
rust/on_reverse_decision_frequency_off 1388 ns/iter
rust/observation_encode 176 ns/iter
rust/observation_encode_forced 174 ns/iter
rust/mask_construction 302 ns/iter

Long-form benchmark docs: docs/performance_benchmarks.md

Compatibility policy

Contract constants are explicit compatibility boundaries:

  • OBS_ENCODING_VERSION=2
  • ACTION_ENCODING_VERSION=1
  • POLICY_VERSION=2
  • REPLAY_SCHEMA_VERSION=2
  • WSDB_SCHEMA_VERSION=2

If encoding/layout semantics change, update code + docs in the same PR:

  1. constants/encode implementation
  2. docs/rl_contract.md checksum table
  3. docs/encodings_changelog.md

License

MIT OR Apache-2.0

Project details


Download files

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

Source Distribution

weiss_sim-0.8.2.tar.gz (724.7 kB view details)

Uploaded Source

Built Distributions

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

weiss_sim-0.8.2-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

weiss_sim-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

weiss_sim-0.8.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.5 MB view details)

Uploaded CPython 3.12macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

weiss_sim-0.8.2-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11Windows x86-64

weiss_sim-0.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

weiss_sim-0.8.2-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.5 MB view details)

Uploaded CPython 3.11macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

weiss_sim-0.8.2-cp310-cp310-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10Windows x86-64

weiss_sim-0.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

weiss_sim-0.8.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.5 MB view details)

Uploaded CPython 3.10macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file weiss_sim-0.8.2.tar.gz.

File metadata

  • Download URL: weiss_sim-0.8.2.tar.gz
  • Upload date:
  • Size: 724.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for weiss_sim-0.8.2.tar.gz
Algorithm Hash digest
SHA256 b2d77833d8c9a000367d059648e24827158342b7b2fdc0653d283cc1eccf7d44
MD5 0e96951903cadc66b4dc3cde756c1167
BLAKE2b-256 de340fd4a92aa68aacc785c447f5ba0229784992f3aa514d515fbe78f47d88dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2.tar.gz:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: weiss_sim-0.8.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for weiss_sim-0.8.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 510de9804254f586aaa33d75071262521e870caad497aa7582497db02abbdf99
MD5 08690b19e3a1722dd25bcb1a7e9d5b18
BLAKE2b-256 470aa820cec88dded4540502d69c6c350159cbdcb173bd5bce7f201f7f45da96

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a84605f8e27c05f494bb138c79b6ee586e0e9fa5316427c73d4b73c4945d19cf
MD5 fb1592b0b3c75c89d9f16379d328c49c
BLAKE2b-256 388a15ebdf83c718e47307a272cecf8e5d7859e82fdf49742f54135a6e667e59

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b17f11f0418795d524db8a145a2256829b1b8222a0664d5c948f9e94ad1eafe3
MD5 22e2f4b929146298297a0955e98ee00b
BLAKE2b-256 04f672fb105aa5ba9f184720ef8fca19b77e42f3fb407a56fd3f7c1da323c741

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: weiss_sim-0.8.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for weiss_sim-0.8.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2fb10abec8f6e0baff45303600988a6f25216c2ea07f93b0b360421c6ec1d79e
MD5 2fafe32a1bf3c7442574f86005cf0570
BLAKE2b-256 047c6e956cde1ad7339252fff8a6fd3c4b086d9bcc24940c3cc4ec90656d11b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 236da1152902689e8ba595c16d0165ed4f9df247420eddf78a42091a2553759f
MD5 80faa28b45e5d0bc689beb80f87cdd14
BLAKE2b-256 7bd8a25e5cb426a38b2f942d954b8ba6977184f5219f0330b13a7280a30c80be

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.2-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 afaaa30fae0a62a1ffc4864678f627815e4ee2b3cd686672f1f93a5c810dd88d
MD5 c0763c73a2b655d73008ee62d1635c67
BLAKE2b-256 1243b0799875c09bcaed745e5224c89ea25b42315b3855795c433eb5216ddc4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: weiss_sim-0.8.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for weiss_sim-0.8.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 54057d512eb338f3d4c9922adcfc477a222264a737fbe58fe2504e6be09cbd17
MD5 d721fd92b7fa8f5a54a2d7c1873cc475
BLAKE2b-256 8d069986448fb5163bcc0beaee7854089720b0a8c00a593ac532f84c7d447cc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7fd5cae9ca794cb8db77b1c074d114c870fcdf41749462a741738a4f3940846a
MD5 c1f1e8c93c85a511ca29711f2efed0ae
BLAKE2b-256 25b6ef1592de0edfe22acd2484ebd0dff722a045707447afec358ffa9014a19b

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

File details

Details for the file weiss_sim-0.8.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 6d6a8b33741ffacb9f3982ef4204b546ecf33602acc6c8dde940a9291a572d2e
MD5 7a9130a3d22a7c55f98241fa462f3af2
BLAKE2b-256 39822c5036b5691dccbe1ef67a2496c949e471c8069ce308659cb8fd24300207

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: wheels.yml on victorwp288/weiss-schwarz-simulator

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page