Skip to main content

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

Project description

Weiss Schwarz Simulator

CI Wheels Benchmarks Security Docs PyPI Changelog

Deterministic Weiss Schwarz simulation for RL and engine research.

  • Rust handles the hot loop (weiss_core)
  • Python provides batched stepping (weiss_sim)
  • The engine advances internally until a decision point, then exposes a stable action-space contract

Why this project

  • Deterministic episodes from seed + action sequence
  • Fixed, versioned observation/action encodings for training pipelines
  • High-throughput EnvPool stepping for large batched RL workloads
  • Replay/fingerprint metadata for drift detection and debugging

5-minute start (Python)

Option A: install from PyPI

python -m pip install -U weiss-sim numpy

Option B: local dev install (Rust + Python)

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

Minimal step loop

Use a real .wsdb path on your machine. The db_path below is a placeholder and the legal_deck ids must exist in that database.

If you are working from source, you can use the fixture DB:

db_path="python/tests/fixtures/cards.wsdb"
from pathlib import Path
import numpy as np
import weiss_sim

db_path = Path("/path/to/your/cards.wsdb")
legal_deck = (list(range(1, 14)) * 4)[:50]

pool = weiss_sim.EnvPool.new_rl_train(
    32,
    str(db_path),
    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)

For training-safe loop semantics and contract details, read docs/rl_contract.md.

Documentation

Primary docs entrypoint: docs/README.md

Recommended reading paths:

  • RL users: docs/quickstart.md -> docs/rl_contract.md -> docs/encodings.md
  • Python integrators: docs/python_api.md -> docs/rl_contract.md
  • Engine contributors: docs/engine_architecture.md -> PROJECT_STATE.md -> docs/rules_coverage.md
  • Performance work: docs/performance_benchmarks.md -> benchmark workflow in .github/workflows/benchmarks.yml

Reference links:

Benchmark Snapshot (main, top 12)

Last updated: 2026-02-16 08:36 UTC

Benchmark Time
rust/advance_until_decision 35677 ns/iter
rust/step_batch_64 15265 ns/iter
rust/reset_batch_256 867903 ns/iter
rust/step_batch_fast_256_priority_off 74124 ns/iter
rust/step_batch_fast_256_priority_on 80038 ns/iter
rust/legal_actions 12 ns/iter
rust/legal_actions_forced 10 ns/iter
rust/on_reverse_decision_frequency_on 1162 ns/iter
rust/on_reverse_decision_frequency_off 1169 ns/iter
rust/observation_encode 178 ns/iter
rust/observation_encode_forced 183 ns/iter
rust/mask_construction 394 ns/iter

Repository layout

  • weiss_core/ Rust engine core
  • weiss_py/ PyO3 bindings
  • python/weiss_sim/ Python API helpers and buffer wrappers
  • python/examples/ benchmark and integration examples
  • python/tests/ Python contract and smoke tests
  • docs/ user/developer documentation hub

Local quality checks

Full CI-equivalent local parity:

scripts/run_local_ci_parity.sh
# Optional during iterative work on thermally constrained machines:
SKIP_BENCHMARKS=1 scripts/run_local_ci_parity.sh

Non-benchmark subset (useful on thermally constrained laptops):

scripts/check_env_layering.sh
python scripts/check_docs_links.py
python scripts/check_docs_constants.py
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace --features test-harness
RUSTDOCFLAGS="-D missing-docs" cargo doc --workspace --no-deps
ruff format --check python scraper scripts
ruff check python scraper scripts
python scripts/ability_coverage_report.py --output /tmp/ability_coverage_report.json
python scripts/ability_coverage_targets.py --report /tmp/ability_coverage_report.json --output /tmp/ability_coverage_targets.json
python scripts/check_coverage_budget.py --report /tmp/ability_coverage_report.json --baseline scripts/ability_coverage_baseline.json --min-parse-line-coverage-strict 0.52 --max-unsupported-lines-strict 14200 --min-card-coverage-approx 0.99
maturin build --release --manifest-path weiss_py/Cargo.toml --out /tmp/wss_dist --interpreter .venv/bin/python
.venv/bin/python -m pip install --force-reinstall --no-deps /tmp/wss_dist/*.whl
.venv/bin/python -m pytest -q python/tests
cargo audit
pip-audit .
pip-audit -r scraper/requirements.txt

Compatibility and versioning

Encoding and schema values are explicit and versioned:

  • OBS_ENCODING_VERSION
  • ACTION_ENCODING_VERSION
  • REPLAY_SCHEMA_VERSION
  • WSDB_SCHEMA_VERSION

If any encoding layout changes, update:

  1. source constants
  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.3.0.tar.gz (296.6 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.3.0-cp312-cp312-win_amd64.whl (902.2 kB view details)

Uploaded CPython 3.12Windows x86-64

weiss_sim-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

weiss_sim-0.3.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.0 MB view details)

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

weiss_sim-0.3.0-cp311-cp311-win_amd64.whl (902.8 kB view details)

Uploaded CPython 3.11Windows x86-64

weiss_sim-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

weiss_sim-0.3.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.0 MB view details)

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

weiss_sim-0.3.0-cp310-cp310-win_amd64.whl (902.9 kB view details)

Uploaded CPython 3.10Windows x86-64

weiss_sim-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

weiss_sim-0.3.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.0 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.3.0.tar.gz.

File metadata

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

File hashes

Hashes for weiss_sim-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ec2bd975fefb15aa700633cfaf9554744a7d94dbcbbccd3606e9a67fa1025e69
MD5 4ed0800ca41de46fe14a026d0232c77a
BLAKE2b-256 8db32b8becda3d24a095d39941f015aa8402d49c482d77c0821f145375f70bb4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 902.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for weiss_sim-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ad6e92877beceafd163f8ff4917ff98312ee4d05257a44c4caa6ff46bd0e6c0b
MD5 d9e7fe2f9f1ec1666522d3287cd15d1e
BLAKE2b-256 415521bb4ae53a68d71e23a1afb4578e8bc309994a27f73c808af2b2818130af

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d6e99db0d8bb83d29eab2cc4bc96e11df26833f22f7ab43062b8f75fb67689ac
MD5 eceaace38d9cac8d64dca430cf3fa1f5
BLAKE2b-256 5b572ecbc2e511b1f41772d6bbed907c793c74a20dedc4cb205cab6172df4fed

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.3.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.3.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.3.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 92634523bf03feba8c35202abdb8e2224545013a57b1d1aedd132c13ac56d1f3
MD5 3297dd7f3cf1b6236ee947df1b514cac
BLAKE2b-256 84009a6a9e860ebc1d5dea66412a6bd7f8e42f02fdfc7f45a0f37b83dde71338

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 902.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for weiss_sim-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 55d11408efba940eae9c6d7adf8656f9adaa7809fd538da7e75eaf946b51849d
MD5 0936d094866db4b049df75bb53e0db3c
BLAKE2b-256 595b520dbc69c1a0c4443224f4a4da10b217999275f98ee6371ea7d899c07179

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c4f1cfdec7bca6facb5c0cf90ac80525d59e3ab1a3a541d6f0e8cca01c17819
MD5 6fac70ae94da50ac6d72b4d9cdfaf509
BLAKE2b-256 6437cdfab800bd2d05bcd19fb6740224b3663a75f56e81abdc583d46e3a70fdb

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.3.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.3.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.3.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 c2b2a4fdcf0e3d5d97510dae945d23188a1d777a6c4fe4365872627a0b8fd175
MD5 ece39b20c652c69b880e90bbb5089f3b
BLAKE2b-256 3eeb4481eeea4ed1b91d033c1c2095ba11689c450facf6e97866ded639029a73

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-0.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 902.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for weiss_sim-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b761c4fb3460e3ae736e7daa99442a15b6f20307afd78ad040a52444539f0e8a
MD5 b258c478566875ab7023dd572c9a953e
BLAKE2b-256 907b3f18bd24e7a237e3394f31164fd554a03bf59f2ac20bb8e98fe173dcc638

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec47d8f2ed8a30438fca8605764093c9eddb7ddc74ca44c5e3faa29692be7698
MD5 4434bf7f791c322528d3a62fa0b62f5e
BLAKE2b-256 5e08ae9f58a7f720b4819e40aa504b68718d038ca284ded4dbb9f2c29fbb5977

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-0.3.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.3.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.3.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fced5e2b85cff06111f1eea253ba2e3169ebf37263bf8100c650c5ed2e97e31e
MD5 be0c9b6d1d93d060f15e808673921186
BLAKE2b-256 f00b564692a9ccbc1c6eca91554583af5f89190cb89e728d3cdae754e4507538

See more details on using hashes here.

Provenance

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