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

Benchmark Time
rust/advance_until_decision 21272 ns/iter
rust/step_batch_64 9581 ns/iter
rust/reset_batch_256 512004 ns/iter
rust/step_batch_fast_256_priority_off 39563 ns/iter
rust/step_batch_fast_256_priority_on 42891 ns/iter
rust/legal_actions 4 ns/iter
rust/legal_actions_forced 4 ns/iter
rust/on_reverse_decision_frequency_on 990 ns/iter
rust/on_reverse_decision_frequency_off 1006 ns/iter
rust/observation_encode 80 ns/iter
rust/observation_encode_forced 79 ns/iter
rust/mask_construction 180 ns/iter
python/reset_into 110.0 us/reset
python/step(mask) 1296605 env-steps/sec
python/step(ids) 1414805 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.1.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.1.0-cp312-cp312-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.12Windows x86-64

weiss_sim-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

weiss_sim-1.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.2 MB view details)

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

weiss_sim-1.1.0-cp311-cp311-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.11Windows x86-64

weiss_sim-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

weiss_sim-1.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.2 MB view details)

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

weiss_sim-1.1.0-cp310-cp310-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.10Windows x86-64

weiss_sim-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

weiss_sim-1.1.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.2 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.1.0.tar.gz.

File metadata

  • Download URL: weiss_sim-1.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 c30c3faa5933894ecbd496dc0cfc71d659325dd6a89288393870a0be467857ae
MD5 239fd585947144422ace1a8140bee111
BLAKE2b-256 56a89a17dca77a3d7ca4c1c8c7e6f87a39cfe5b1e6bbfde3f75920c63ebc75db

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.1 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.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3881a9f06c1021a58ee1323eaceb7a408ffc1cf21a278ac22d38016c75f19ebb
MD5 1289b90964e8fdb00f247a5e48025802
BLAKE2b-256 54734fb40fd716de126dbf01590765f723bea8ef4e25f4fa15e396d546c46f71

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3207616cd2a328bea5bed6337da0d277648f7c1cd78979b0620e684f52baccbf
MD5 0029d03bc7169bf4694cc41ebc7ef495
BLAKE2b-256 60451509981c538ede0729b5d1b6f43d545887f2c4bc6c1c80246f0dae928659

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.1.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.1.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.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 4595660dfaecb480448fd6dd469864bbfa5df6c85c8f058f24b908ea17e96f3d
MD5 cb1f6b3542f514b1e4ad0954f661d41e
BLAKE2b-256 d30c8b5b816668e1064d4b24df096048deeafdc1a7024cc032fe7f268914b980

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.1 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.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0b97a5dedec618249a595787f5781a0f7ff82c4f9ec8cbdee07b70d5de7964c3
MD5 47c181e74516a771de3411dc5dceb5c9
BLAKE2b-256 488e8ecd9d32bef9e45f47db9de8c6501ea574ff8151feca056b2a4721343125

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aca48369a83d58ca1034eaf1c3db0d9d98acbf3f616054b5e4e3bd489541e2ec
MD5 1884ac2e90820602c44693260660d74c
BLAKE2b-256 c8b852f079f3fef9bfd1ad1d8df396252dc96f75fb206d1b1948bb03b2224654

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.1.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.1.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.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 7ace54e1f64a1971f3acdca13b328655fca6c8faab85e175fe8455756e3bcf60
MD5 53595c53405f90b4d1e3b9a7c923cd27
BLAKE2b-256 18362c122d417ebb09a7cbf3c3d9e1f0b5aca4e176eaaedfc31f78eff7e13c1a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.1 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.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6b7eef96e5e88de42ca564fb2a03b67575ccd9a624698d4b6936d5d2eb7933ec
MD5 fdc4bd9b2e38038b0fa10e649d7f7918
BLAKE2b-256 3a4205a8e03da964fa0cf0387bcb960638b9699de2442789e4cade7b0dc9a438

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 38dfbf20582181782a72575d2a5c57eab2560a5560da359d2a494606ce6b7e7e
MD5 7558ec930062f4eba6acd16c5d337673
BLAKE2b-256 cd6a9c50c3dcba8ad6eff94246035480277416b1a91744458232c1faa0b6bc05

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.1.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.1.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.1.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 d917d62dc8ea800ae575b67a0d7f6a0b98085f1c7d8dc6b9e531ea9fb00eead5
MD5 b2d5ab83582b0f4c69927dd09b9cb792
BLAKE2b-256 424973c0179088e008da6ed45a537b43a2e4a5ba22d9c1e2b6ab9bbdd415b415

See more details on using hashes here.

Provenance

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