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 11:47 UTC

Benchmark Time
rust/advance_until_decision 46413 ns/iter
rust/step_batch_64 15017 ns/iter
rust/reset_batch_256 821945 ns/iter
rust/step_batch_fast_256_priority_off 67538 ns/iter
rust/step_batch_fast_256_priority_on 67542 ns/iter
rust/legal_actions 11 ns/iter
rust/legal_actions_forced 10 ns/iter
rust/on_reverse_decision_frequency_on 1281 ns/iter
rust/on_reverse_decision_frequency_off 1310 ns/iter
rust/observation_encode 185 ns/iter
rust/observation_encode_forced 190 ns/iter
rust/mask_construction 332 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.1.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.1-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

weiss_sim-0.8.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: weiss_sim-0.8.1.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.1.tar.gz
Algorithm Hash digest
SHA256 77c013e8bd861f382cfdcf7d58fdeb466c31d677791af46df7bb4e1c758b6589
MD5 2bae6efa1e1d5d1b031f7a8401fb03f7
BLAKE2b-256 7a473358f651b6b488da45b869adfad895c4c98fdc72ec21a22fa6d2d828e947

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-0.8.1-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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1ca95648ad88efbfb728bed2f5d9bf341e93a1f917272bb66141fe64279e965b
MD5 94ca1d1f6647510e3b46701b490cd70f
BLAKE2b-256 bf3afab1c64c3aa3dfdaf1d46d8577b2ee0291d86ae22688ad1f40d3889c7fa7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-0.8.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9f02f12a2e19d9060a43b5eb274a8c0fa206034657a820a0ace04b22cae0334
MD5 6d241f1900acd9824b379d24fee4a4b4
BLAKE2b-256 2f08c15102a53e139543e7c011bc3a004b1d55ac0402e4b7e41006626e00fdcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.1-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.1-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.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 ad00a3f52714bc3041a368380a4b05732c6a804ab0b2f965b810bb0b0189ac84
MD5 66e9e06de15202113ff00326a8a7122b
BLAKE2b-256 155e9eefb4117a017af4721f1190f8aa64014fb4d73dee5c9059e54d931d6e52

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-0.8.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b9b9afcccb8f30e54401ee0ab7d0352468dd5ef820a99b1a5fe1a99d76604527
MD5 e4aac5e865e320c7f4d63f11c3fd3cf7
BLAKE2b-256 2d91d94402283477132c9a7231043dbbbfa2975d11f5d3b61fb80fb6052f7a5c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-0.8.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3a03130c69961995c855388d38771527a818df26a45854d3134a3e06c2d8aec
MD5 60b6446297f0a1ce7435d4edfd86aa18
BLAKE2b-256 e83d7a29f89fb5427539c05a2fb8245193b955aa7d711c929ca7546fa0021a0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.1-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.1-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.1-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 cc7b108c8dcc9a7d7f34f7868d34d669455e225742ba331422e3e4522c769f0c
MD5 ad8e0f6333832a02b2b555c6bc8ff88c
BLAKE2b-256 37d44ef167eee0c8945966ec79551611fa185e2ffe52d509b743ed2b40806f73

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-0.8.1-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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8a0b674aea600132af404e58aca1cd89c9602ee49bf6138f9336bbaf611c07ba
MD5 11e327720da334cefd112aeb6d12e769
BLAKE2b-256 2f2d3f2e88f5950c228e5a2ea892a970a0379711e68cf737eeeeaa292d5e4ab1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-0.8.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 468f18cfb3f32801bdec2f46b1afa8b6b9f6ac9293a64fdce9a8a94173f9e47a
MD5 96ba7ff3e2f7c74228087f1bc6b4d6d6
BLAKE2b-256 e8c19f74985440b8b2db9ee01b2e70f43a46cd9eada96fb80539688a6673aa6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.8.1-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.1-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.1-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 8f4538ecb5f9348da18d21b65cec175802a0d2b215352f50d0987599adbe3558
MD5 e2879d93ada25173723c29abd239ebfa
BLAKE2b-256 b1c223a0fd4a324e94e97aa1041b2f13dec5d40c98992116f2af26ba7a4774ae

See more details on using hashes here.

Provenance

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