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, batched Weiss Schwarz simulation for reinforcement learning 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)
  • RL-oriented fast paths for packed legal ids, no-metadata layouts, fused sampled log-prob stepping, and optional legal-action context tensors
  • Replay and fingerprint surfaces for drift detection and reproducibility

Release status

1.1.0 is the stabilized research release line. Public compatibility boundaries are documented explicitly, and any future encoding, replay, WSDB, or action-space changes should update the corresponding version constants and docs in the same change.

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, buf = weiss_sim.make_pool(
    mode="train",
    num_envs=32,
    deck_lists=[legal_deck, legal_deck],
    deck_ids=[1, 2],
    seed=0,
    layout="i16_legal_ids_nometa",
)
out = buf.reset()
actions = np.full(pool.envs_len, weiss_sim.PASS_ACTION_ID, dtype=np.uint32)
out = buf.step(actions)

Throughput-sensitive policy-gradient loops should prefer the fused sampled-logp helper when they need both sampled actions and behavior log-probabilities:

logits = np.zeros((pool.envs_len, weiss_sim.ACTION_SPACE_SIZE), dtype=np.float32)
seeds = np.arange(pool.envs_len, dtype=np.uint64)
step, actions, logp = buf.step_sample_from_logits_with_logp(logits, seeds)

Deck authoring flow (Python)

import weiss_sim

builder = weiss_sim.cards.builder(initial="starter_deck_ws02_v1")
report = builder.validate(rules_profile="approx", card_pool="all")
if report.ok:
    deck_ids = builder.build(rules_profile="approx", card_pool="all")

Bundled presets are the four release decklists: starter_deck_ws02_v1, control_deck_jj_s66_v1, main_deck_5hy_yotsuba_v1, and aggro_deck_5hy_nino_v1. Inspect the installed package with weiss_sim.cards.presets(). These presets require rules_profile="approx" because they include partially parsed card abilities.

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. The docs are intentionally compact:

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
  • .github/: CI, release, issue, and pull request templates

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-05-12 12:43 UTC

Benchmark Time
rust/advance_until_decision 50005 ns/iter
rust/step_batch_64 16198 ns/iter
rust/reset_batch_256 795905 ns/iter
rust/reset_i16_legal_ids_256 786824 ns/iter
rust/reset_i16_legal_ids_nometa_256 789806 ns/iter
rust/step_batch_fast_256_priority_off 82100 ns/iter
rust/step_batch_fast_256_priority_on 83023 ns/iter
rust/step_first_legal_i16_legal_ids_256 245624 ns/iter
rust/step_first_legal_i16_legal_ids_nometa_256 227727 ns/iter
rust/rollout_heuristic_public_i16_legal_ids_256x16 5075727 ns/iter
rust/legal_actions 13 ns/iter
rust/legal_actions_forced 12 ns/iter
python/reset_into 310.4 us/reset
python/step(mask) 840219 env-steps/sec
python/step(ids) 708547 env-steps/sec

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=3
  • 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/architecture.md compatibility notes when replay/WSDB/runtime boundaries change

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-1.2.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distributions

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

weiss_sim-1.2.0-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

weiss_sim-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

weiss_sim-1.2.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.4 MB view details)

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

weiss_sim-1.2.0-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

weiss_sim-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

weiss_sim-1.2.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.4 MB view details)

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

weiss_sim-1.2.0-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

weiss_sim-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

weiss_sim-1.2.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.4 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-1.2.0.tar.gz.

File metadata

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

File hashes

Hashes for weiss_sim-1.2.0.tar.gz
Algorithm Hash digest
SHA256 83ab5b6a36295976937c1203bdd32f234ff83a91ae9571e1a616fece2312a0e1
MD5 0bc6bace95350e8a334e1a56c7580c3c
BLAKE2b-256 1f14658b405caafc008b0f21cf186587c0d9c898707ca57b29939f5077ca8ef0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.2 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-1.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 73c82d46d94daae80afd2ff606f38450f0f5cfda8a6da426de2378925f68c187
MD5 260033fc94078168713032b4992a26e5
BLAKE2b-256 4b8c53a82f2f1b46e3f6c0b36501d34ea160e264aecb6fed15354eea2031e51a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84999e8c65efec8a489e2f94e6b0c8a2ed8b8609d813ad6ff5dec5a1cb85ccd3
MD5 d0c59c8af88b0efbfe1a6f64a747c5a9
BLAKE2b-256 7e9bd42f8a1f101f734e24911a04be6dc1fc59f7b591606d4850fad0fac96209

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.2.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-1.2.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-1.2.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 664ce674a9d383de38357e951e98c0956f66ada5371e8838743406da10c61b74
MD5 882a9884aca2a8c700c9595bbf51f577
BLAKE2b-256 c6edb9c7b2f730952a20201e6d80684a778effd6a791f7034a12087eedd6de72

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.2 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-1.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 099497d932735a49c22a7c2d6a87852b49690eb00473b26ff2bd4fbf754713f7
MD5 5354f84904da46062429a29207179f2f
BLAKE2b-256 269a2b6898595c84cd65a130e135712bfd0a3f2488fe949c8104e0eb8189e53c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9c4bdcfa9fa3fbf2962a37cbcaf91a1b27b675a3d1f2f99c4e28d345da31809
MD5 c6c3d7dd458a1f0afe917641ff3e00d0
BLAKE2b-256 b61f13836d4caddd3bde73225c768c76d63b5e8e1754491e1f0e2ce2f1a9c34e

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.2.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-1.2.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-1.2.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 d82e9a6c78e1e5f1ba9fcc1878024a1e32d6dc1fd1010d1ac306e56fe893ec6c
MD5 8d036db2996e43634b5ef630c2d0fd75
BLAKE2b-256 ff2ef3ec4315b1d03a0e8abe83cf3e377a1956d7b1a6b32bfcb3c3b9b97f9663

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.2 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-1.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 592e7e904d46571d72ba97a47858ec2883ac62f08448d7fd1096b7ad30c48e00
MD5 1a54d7bfd096d34e3a19058599f0ef73
BLAKE2b-256 8de8e970411cb6161fe5f0cbe2dfee9ccdb9ae30582e4712429a66e3ffae97e1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3fadabb874686dea28bb88f5fcf547303cf8003f1ef695643943d423bfb1b3bb
MD5 872dbb364d167c0d0e5b16d271c80826
BLAKE2b-256 d6bfdd1e37e5dfd64661366efeddadb4f8301c0d71352c276ac352511cc8463f

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.2.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-1.2.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-1.2.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 93e86ee856f4708d868623e15e0ac8b8dbfb174c59b1d1cd93d6fc844d5c55fe
MD5 46d8015c0d28fc0562b270934bebfecb
BLAKE2b-256 8e8b4cf4df4f4961e9cb10abbc2a68721f4e2873ccf8d9de7e46221e0225916f

See more details on using hashes here.

Provenance

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