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-20 09:50 UTC

Benchmark Time
rust/advance_until_decision 46132 ns/iter
rust/step_batch_64 15603 ns/iter
rust/reset_batch_256 860159 ns/iter
rust/step_batch_fast_256_priority_off 87326 ns/iter
rust/step_batch_fast_256_priority_on 87674 ns/iter
rust/legal_actions 11 ns/iter
rust/legal_actions_forced 11 ns/iter
rust/on_reverse_decision_frequency_on 1458 ns/iter
rust/on_reverse_decision_frequency_off 1425 ns/iter
rust/observation_encode 182 ns/iter
rust/observation_encode_forced 181 ns/iter
rust/mask_construction 297 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.0.tar.gz (723.5 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.0-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

weiss_sim-0.8.0-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.0-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.0-cp311-cp311-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.11Windows x86-64

weiss_sim-0.8.0-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.0-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.0-cp310-cp310-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10Windows x86-64

weiss_sim-0.8.0-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.0-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.0.tar.gz.

File metadata

  • Download URL: weiss_sim-0.8.0.tar.gz
  • Upload date:
  • Size: 723.5 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.0.tar.gz
Algorithm Hash digest
SHA256 b1d7141d7a355d922d368956d4d3780898fa9feb3c22a718d19fbdaf46a88e29
MD5 a99728af1e29af94586aa7810192dd79
BLAKE2b-256 3ffa2b90ab55175c615f404175c0bd390b2aef185a9424dd4141016041196f57

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0.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.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: weiss_sim-0.8.0-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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1674fae0f2364a32ea5d1e9587e542275293684992c678bb18457ce7fa3257f8
MD5 357529d19f2aba5370df1255ef8d8e3c
BLAKE2b-256 2db008a59102f5135c45ea8c7cdede4abfcb02f1b7e2578533324a6c02deda5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8509beb839f32cbdfa07481aba00a9f9db3f42d8d35ff98d9184097a215507c0
MD5 81f299d5a1d2ace3f57b4cd92db5e81a
BLAKE2b-256 2ed40a0ee93bdf2b36c3d9cec367b6da1bdb2e8e944528a5d2d92476d7c91215

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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.0-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.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 003af1a1a0cfcc695e02a864d54f793bf68b29ca0d51b960b4fb1208a9e86351
MD5 1e1eb72162eb45d3d3043730bb1c180f
BLAKE2b-256 2d1c18fe62e724ae61479562a86888da528fd7a37930758c106bb93fda32a635

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: weiss_sim-0.8.0-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.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fa67191cc41c6d8838f5d50b382a31bbdeaf8dc8a6e7fa9703d18420d8ecd4d5
MD5 a0a59ffd339b0fe1d94da5fc8a8f5f58
BLAKE2b-256 5c70f19b6a643ecdb7a9c9ecfae294d77ccc4afb76124e2de2959004f87efb9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c89bca9b7589648030eb436ab43bd3fe0bb01b8df0fb6fb439453424ff80a69
MD5 baddcad917bcf5c0e43a219205e86971
BLAKE2b-256 71f2c1a3b931a191a2bc416d8a4fdffaaf3886ba70dfbad536d222544bfb2b61

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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.0-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.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 50a682e0efc1a79b811cd18ebe024fa4bc96188a51f4f5170750581f541640f0
MD5 79abbe830e8cd74cac218cb7b8defd1d
BLAKE2b-256 132fef618325598378638a8f4aca006bc1e029f07533d1ffe3ffe70cc3c21e88

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: weiss_sim-0.8.0-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.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 12079d3d63be2290ed84bd7c4e5178f42cc7048cff3b8816539e5c671ac849b7
MD5 55a8bd3c53406619af4b33a959c71783
BLAKE2b-256 180194bb2f0c5647a8186b58363018bc48366c80ed82cc5e95379ca105be6847

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for weiss_sim-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 858799b75e79eed15971e984076fc19d5a758d36402bb175b4f75a469b3ab5ae
MD5 28b5964a9723228fb5b76b7bc605cdfe
BLAKE2b-256 09b0116894971152d2b49a7948452b721b74d5e3a20407a0671a99fe68b14fd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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.0-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.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 8495d3de3aed5324b6303228488e6d2061cc48e696dc9618c047b134f3136bc0
MD5 53bac7a13e1112ae26d09bad8a2074da
BLAKE2b-256 a805ae4cb12a8b03461d1739169f2d5ecc2da7423d30b35b119a7d2b176bfd4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.0-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