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.0.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-11

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
rust/mask_construction_forced 178 ns/iter
python/reset_into 75.8 us/reset
python/step(mask) 2602377 env-steps/sec
python/step(ids) 4929457 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.0.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.0.0-cp312-cp312-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.12Windows x86-64

weiss_sim-1.0.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.0.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.0.0-cp311-cp311-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.11Windows x86-64

weiss_sim-1.0.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.0.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.0.0-cp310-cp310-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.10Windows x86-64

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

File metadata

  • Download URL: weiss_sim-1.0.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.0.0.tar.gz
Algorithm Hash digest
SHA256 cb0da9831ee8817b11b39e80d5992312f3984935e914b8372a673b45c92ee23e
MD5 770409245ae453ca559fe2f8ab3fff73
BLAKE2b-256 a8b3a4b1aeb5548e563d0fa54116be70fb43f53bf5e2bbc08f9e83ec609e63c9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.0.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.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 91b1960bf7d988316e93adb3de9c113557425b0226f977a934491c10d0966baa
MD5 fe6ab4b874aa3faa2611511f31f6af60
BLAKE2b-256 d98be57fcd38ef52c9114ea4b6b0f75a2318158590d97f5cee855cd75838a63a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cc760ef08b6752a5fad9df379a6c7905f6f4618710ccab63078369add5a42e84
MD5 fb4e31ba556c83aa28a1b2954b02c07e
BLAKE2b-256 407f8821f5debb530c295e48c4d8bd4cfe121bb398435f5da5e4abf1047dd681

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.0.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.0.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.0.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 8d9fc64324197859704abfe51ff608c672b2ec5b6a9e1da35bcb393ce716aaae
MD5 f72591c45bc21399f2177ac79ac798d4
BLAKE2b-256 727b8d3b7a8cda379443e6a2e008f2b9fa4d8e4771e39f17d1d0469d357143ee

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.0.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.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f7f6e7f79398be0ebb05776cc7da72b26efb51905bcd3c8a40cd12b1f80554f1
MD5 3c8f28c4efff91f9e4bc8e8eb3d8dac9
BLAKE2b-256 c04b6047ebb47013c643cf491092e1a06491a42d414ba8fa35d85c395abcc049

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b57fa80c6a1c9536d03f6d01dc2499eca5a27d0781ead210e066e404ca41de3d
MD5 b827676590b2fd3fd7a601d36109582a
BLAKE2b-256 594f9c8239395959b2038e8cd27c5105917ed05d1ca1e3fbdd0d7536241d3463

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.0.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.0.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.0.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 9a54d9ce18bd4b574d59009d5e1dd6519ece40ba3d93b06df70e8a1da9a6f05d
MD5 2312f111755805c4618c98256bd746b1
BLAKE2b-256 89e8b7b3d3c1f02c8510248d2ecf48ff359b147c5b14dcdf96aee1148eeaaf57

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: weiss_sim-1.0.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.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e95e64950f71484f793dfc8e00e820cd343918afa81aa616244cd6f5e0716b41
MD5 0351201d6bd51cbadf28de399dfca2a4
BLAKE2b-256 361dd2d799bc7da904617cecbe922773842bc97427c9ef52f854d02bd038a4d3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for weiss_sim-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 404886e139db449fae3cb117138938c0f404b4f5b8ed94f6c0324b56a08d8de5
MD5 41ff53563cbf4cd2e0c049c89b275a69
BLAKE2b-256 c6b92a487457e45e50afcb82830c3389a47db38bf28cabfab0f9e4634c232f9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for weiss_sim-1.0.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.0.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.0.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 bc9ec6dc3cba43806d9816f1aed73e6f24966a62299b5b900363bfb798ab655c
MD5 2546702a8e04b16fa3b918a2d34d8ea0
BLAKE2b-256 adf88ece78dad6b076a7a5e6a176bcfcdadeba2aea81b273dc377a109acb2b48

See more details on using hashes here.

Provenance

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